beam-core-0.8.0.0: Type-safe, feature-complete SQL query and manipulation interface for Haskell

Safe HaskellNone
LanguageHaskell2010

Database.Beam.Query

Contents

Synopsis

Query type

data QWindow be s Source #

Instances
contextPredicate QWindowFrameContext => ProjectibleWithPredicate contextPredicate be (WithExprContext (BeamSqlBackendWindowFrameSyntax' be)) (QWindow be s) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

project' :: Monad m => Proxy contextPredicate -> Proxy (be, WithExprContext (BeamSqlBackendWindowFrameSyntax' be)) -> (forall context. contextPredicate context => Proxy context -> Proxy be -> WithExprContext (BeamSqlBackendWindowFrameSyntax' be) -> m (WithExprContext (BeamSqlBackendWindowFrameSyntax' be))) -> QWindow be s -> m (QWindow be s) Source #

projectSkeleton' :: Monad m => Proxy contextPredicate -> Proxy (be, WithExprContext (BeamSqlBackendWindowFrameSyntax' be)) -> (forall context. contextPredicate context => Proxy context -> Proxy be -> m (WithExprContext (BeamSqlBackendWindowFrameSyntax' be))) -> m (QWindow be s) Source #

type QExpr = QGenExpr QValueContext Source #

QGenExprs represent expressions not containing aggregates.

newtype QGenExpr context be s t Source #

The type of lifted beam expressions that will yield the haskell type t.

context is a type-level representation of the types of expressions this can contain. For example, QAggregateContext represents expressions that may contain aggregates, and QWindowingContext represents expressions that may contain OVER.

syntax is the expression syntax being built (usually a type that implements IsSql92ExpressionSyntax at least, but not always).

s is a state threading parameter that prevents QGenExprs from incompatible sources to be combined. For example, this is used to prevent monadic joins from depending on the result of previous joins (so-called LATERAL joins).

Instances
(Beamable t, contextPredicate context) => ProjectibleWithPredicate contextPredicate be (WithExprContext (BeamSqlBackendExpressionSyntax' be)) (t (Nullable (QGenExpr context be s))) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

project' :: Monad m => Proxy contextPredicate -> Proxy (be, WithExprContext (BeamSqlBackendExpressionSyntax' be)) -> (forall context0. contextPredicate context0 => Proxy context0 -> Proxy be -> WithExprContext (BeamSqlBackendExpressionSyntax' be) -> m (WithExprContext (BeamSqlBackendExpressionSyntax' be))) -> t (Nullable (QGenExpr context be s)) -> m (t (Nullable (QGenExpr context be s))) Source #

projectSkeleton' :: Monad m => Proxy contextPredicate -> Proxy (be, WithExprContext (BeamSqlBackendExpressionSyntax' be)) -> (forall context0. contextPredicate context0 => Proxy context0 -> Proxy be -> m (WithExprContext (BeamSqlBackendExpressionSyntax' be))) -> m (t (Nullable (QGenExpr context be s))) Source #

(Beamable t, contextPredicate context) => ProjectibleWithPredicate contextPredicate be (WithExprContext (BeamSqlBackendExpressionSyntax' be)) (t (QGenExpr context be s)) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

project' :: Monad m => Proxy contextPredicate -> Proxy (be, WithExprContext (BeamSqlBackendExpressionSyntax' be)) -> (forall context0. contextPredicate context0 => Proxy context0 -> Proxy be -> WithExprContext (BeamSqlBackendExpressionSyntax' be) -> m (WithExprContext (BeamSqlBackendExpressionSyntax' be))) -> t (QGenExpr context be s) -> m (t (QGenExpr context be s)) Source #

projectSkeleton' :: Monad m => Proxy contextPredicate -> Proxy (be, WithExprContext (BeamSqlBackendExpressionSyntax' be)) -> (forall context0. contextPredicate context0 => Proxy context0 -> Proxy be -> m (WithExprContext (BeamSqlBackendExpressionSyntax' be))) -> m (t (QGenExpr context be s)) Source #

contextPredicate context => ProjectibleWithPredicate contextPredicate be (WithExprContext (BeamSqlBackendExpressionSyntax' be)) (QGenExpr context be s a) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

project' :: Monad m => Proxy contextPredicate -> Proxy (be, WithExprContext (BeamSqlBackendExpressionSyntax' be)) -> (forall context0. contextPredicate context0 => Proxy context0 -> Proxy be -> WithExprContext (BeamSqlBackendExpressionSyntax' be) -> m (WithExprContext (BeamSqlBackendExpressionSyntax' be))) -> QGenExpr context be s a -> m (QGenExpr context be s a) Source #

projectSkeleton' :: Monad m => Proxy contextPredicate -> Proxy (be, WithExprContext (BeamSqlBackendExpressionSyntax' be)) -> (forall context0. contextPredicate context0 => Proxy context0 -> Proxy be -> m (WithExprContext (BeamSqlBackendExpressionSyntax' be))) -> m (QGenExpr context be s a) Source #

Beamable tbl => ThreadRewritable s (tbl (Nullable (QGenExpr ctxt syntax s))) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Associated Types

type WithRewrittenThread s s' (tbl (Nullable (QGenExpr ctxt syntax s))) :: Type Source #

Methods

rewriteThread :: Proxy s' -> tbl (Nullable (QGenExpr ctxt syntax s)) -> WithRewrittenThread s s' (tbl (Nullable (QGenExpr ctxt syntax s))) Source #

Beamable tbl => ThreadRewritable s (tbl (QGenExpr ctxt syntax s)) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Associated Types

type WithRewrittenThread s s' (tbl (QGenExpr ctxt syntax s)) :: Type Source #

Methods

rewriteThread :: Proxy s' -> tbl (QGenExpr ctxt syntax s) -> WithRewrittenThread s s' (tbl (QGenExpr ctxt syntax s)) Source #

(BeamSqlBackend be, Beamable t) => SqlDeconstructMaybe be (t (Nullable (QGenExpr ctxt be s))) (t (QGenExpr ctxt be s)) s Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

isJust_ :: t (Nullable (QGenExpr ctxt be s)) -> QGenExpr ctxt0 be s Bool Source #

isNothing_ :: t (Nullable (QGenExpr ctxt be s)) -> QGenExpr ctxt0 be s Bool Source #

maybe_ :: QGenExpr ctxt0 be s y -> (t (QGenExpr ctxt be s) -> QGenExpr ctxt0 be s y) -> t (Nullable (QGenExpr ctxt be s)) -> QGenExpr ctxt0 be s y Source #

ThreadRewritable s (QGenExpr ctxt syntax s a) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Associated Types

type WithRewrittenThread s s' (QGenExpr ctxt syntax s a) :: Type Source #

Methods

rewriteThread :: Proxy s' -> QGenExpr ctxt syntax s a -> WithRewrittenThread s s' (QGenExpr ctxt syntax s a) Source #

BeamSqlBackend be => SqlDeconstructMaybe be (QGenExpr ctxt be s (Maybe x)) (QGenExpr ctxt be s x) s Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

isJust_ :: QGenExpr ctxt be s (Maybe x) -> QGenExpr ctxt0 be s Bool Source #

isNothing_ :: QGenExpr ctxt be s (Maybe x) -> QGenExpr ctxt0 be s Bool Source #

maybe_ :: QGenExpr ctxt0 be s y -> (QGenExpr ctxt be s x -> QGenExpr ctxt0 be s y) -> QGenExpr ctxt be s (Maybe x) -> QGenExpr ctxt0 be s y Source #

Beamable tbl => ContextRewritable (tbl (Nullable (QGenExpr old syntax s))) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Associated Types

type WithRewrittenContext (tbl (Nullable (QGenExpr old syntax s))) ctxt :: Type Source #

Methods

rewriteContext :: Proxy ctxt -> tbl (Nullable (QGenExpr old syntax s)) -> WithRewrittenContext (tbl (Nullable (QGenExpr old syntax s))) ctxt Source #

Beamable tbl => ContextRewritable (tbl (QGenExpr old syntax s)) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Associated Types

type WithRewrittenContext (tbl (QGenExpr old syntax s)) ctxt :: Type Source #

Methods

rewriteContext :: Proxy ctxt -> tbl (QGenExpr old syntax s) -> WithRewrittenContext (tbl (QGenExpr old syntax s)) ctxt Source #

(Beamable table, BeamSqlBackend be, FieldsFulfillConstraintNullable (BeamSqlBackendCanSerialize be) table) => SqlValable (table (Nullable (QGenExpr ctxt be s))) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

val_ :: HaskellLiteralForQExpr (table (Nullable (QGenExpr ctxt be s))) -> table (Nullable (QGenExpr ctxt be s)) Source #

(Beamable table, BeamSqlBackend be, FieldsFulfillConstraint (BeamSqlBackendCanSerialize be) table) => SqlValable (table (QGenExpr ctxt be s)) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

val_ :: HaskellLiteralForQExpr (table (QGenExpr ctxt be s)) -> table (QGenExpr ctxt be s) Source #

(Table t, BeamSqlBackend be) => SqlJustable (t (QExpr be s)) (t (Nullable (QExpr be s))) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

just_ :: t (QExpr be s) -> t (Nullable (QExpr be s)) Source #

nothing_ :: t (Nullable (QExpr be s)) Source #

Beamable tbl => QGroupable (tbl (Nullable (QExpr be s))) (tbl (Nullable (QGroupExpr be s))) Source #

group_ for any Beamable type. Adds every field in the type to the grouping key. This is the equivalent of including the grouping expression of each field in the type as part of the aggregate projection

Instance details

Defined in Database.Beam.Query.Aggregate

Methods

group_ :: tbl (Nullable (QExpr be s)) -> tbl (Nullable (QGroupExpr be s)) Source #

Beamable tbl => QGroupable (tbl (QExpr be s)) (tbl (QGroupExpr be s)) Source #

group_ for any Beamable type. Adds every field in the type to the grouping key. This is the equivalent of including the grouping expression of each field in the type as part of the aggregate projection

Instance details

Defined in Database.Beam.Query.Aggregate

Methods

group_ :: tbl (QExpr be s) -> tbl (QGroupExpr be s) Source #

(Table t, BeamSqlBackend be) => SqlJustable (PrimaryKey t (QExpr be s)) (PrimaryKey t (Nullable (QExpr be s))) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

just_ :: PrimaryKey t (QExpr be s) -> PrimaryKey t (Nullable (QExpr be s)) Source #

nothing_ :: PrimaryKey t (Nullable (QExpr be s)) Source #

(BeamSqlBackend be, Beamable tbl, FieldsFulfillConstraintNullable (HasSqlEqualityCheck be) tbl) => SqlEq (QGenExpr context be s) (tbl (Nullable (QGenExpr context be s))) Source # 
Instance details

Defined in Database.Beam.Query.Ord

Methods

(==.) :: tbl (Nullable (QGenExpr context be s)) -> tbl (Nullable (QGenExpr context be s)) -> QGenExpr context be s Bool Source #

(/=.) :: tbl (Nullable (QGenExpr context be s)) -> tbl (Nullable (QGenExpr context be s)) -> QGenExpr context be s Bool Source #

(==?.) :: tbl (Nullable (QGenExpr context be s)) -> tbl (Nullable (QGenExpr context be s)) -> QGenExpr context be s SqlBool Source #

(/=?.) :: tbl (Nullable (QGenExpr context be s)) -> tbl (Nullable (QGenExpr context be s)) -> QGenExpr context be s SqlBool Source #

(BeamSqlBackend be, Beamable tbl, FieldsFulfillConstraint (HasSqlEqualityCheck be) tbl) => SqlEq (QGenExpr context be s) (tbl (QGenExpr context be s)) Source #

Compare two arbitrary Beamable types containing QGenExprs for equality.

Instance details

Defined in Database.Beam.Query.Ord

Methods

(==.) :: tbl (QGenExpr context be s) -> tbl (QGenExpr context be s) -> QGenExpr context be s Bool Source #

(/=.) :: tbl (QGenExpr context be s) -> tbl (QGenExpr context be s) -> QGenExpr context be s Bool Source #

(==?.) :: tbl (QGenExpr context be s) -> tbl (QGenExpr context be s) -> QGenExpr context be s SqlBool Source #

(/=?.) :: tbl (QGenExpr context be s) -> tbl (QGenExpr context be s) -> QGenExpr context be s SqlBool Source #

BeamSqlBackend be => SqlJustable (QExpr be s a) (QExpr be s (Maybe a)) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

just_ :: QExpr be s a -> QExpr be s (Maybe a) Source #

nothing_ :: QExpr be s (Maybe a) Source #

QGroupable (QExpr be s a) (QGroupExpr be s a) Source #

group_ for simple value expressions.

Instance details

Defined in Database.Beam.Query.Aggregate

Methods

group_ :: QExpr be s a -> QGroupExpr be s a Source #

BeamSqlBackend be => SqlOrdQuantified (QGenExpr context be s) (QQuantified be s a) (QGenExpr context be s a) Source # 
Instance details

Defined in Database.Beam.Query.Ord

Methods

(<*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool Source #

(>*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool Source #

(<=*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool Source #

(>=*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool Source #

(BeamSqlBackend be, HasSqlQuantifiedEqualityCheck be a) => SqlEqQuantified (QGenExpr context be s) (QQuantified be s a) (QGenExpr context be s a) Source #

Two arbitrary expressions can be quantifiably compared for equality.

Instance details

Defined in Database.Beam.Query.Ord

Methods

(==*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s SqlBool Source #

(/=*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s SqlBool Source #

Retaggable (QGenExpr ctxt expr s) (QGenExpr ctxt expr s t) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Associated Types

type Retag tag (QGenExpr ctxt expr s t) :: Type Source #

Methods

retag :: (forall a. Columnar' (QGenExpr ctxt expr s) a -> Columnar' (tag (QGenExpr ctxt expr s)) a) -> QGenExpr ctxt expr s t -> Retag tag (QGenExpr ctxt expr s t) Source #

BeamSqlBackend be => SqlOrd (QGenExpr context be s) (QGenExpr context be s a) Source # 
Instance details

Defined in Database.Beam.Query.Ord

Methods

(<.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool Source #

(>.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool Source #

(<=.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool Source #

(>=.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool Source #

(BeamSqlBackend be, HasSqlEqualityCheck be a) => SqlEq (QGenExpr context be s) (QGenExpr context be s a) Source #

Compare two arbitrary expressions (of the same type) for equality

Instance details

Defined in Database.Beam.Query.Ord

Methods

(==.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool Source #

(/=.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool Source #

(==?.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s SqlBool Source #

(/=?.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s SqlBool Source #

BeamSqlBackend be => Eq (QGenExpr context be s t) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

(==) :: QGenExpr context be s t -> QGenExpr context be s t -> Bool #

(/=) :: QGenExpr context be s t -> QGenExpr context be s t -> Bool #

(Fractional a, BeamSqlBackend be, BeamSqlBackendCanSerialize be a) => Fractional (QGenExpr context be s a) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

(/) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s a #

recip :: QGenExpr context be s a -> QGenExpr context be s a #

fromRational :: Rational -> QGenExpr context be s a #

(Num a, BeamSqlBackend be, BeamSqlBackendCanSerialize be a) => Num (QGenExpr context be s a) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

(+) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s a #

(-) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s a #

(*) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s a #

negate :: QGenExpr context be s a -> QGenExpr context be s a #

abs :: QGenExpr context be s a -> QGenExpr context be s a #

signum :: QGenExpr context be s a -> QGenExpr context be s a #

fromInteger :: Integer -> QGenExpr context be s a #

(BeamSqlBackend backend, BeamSqlBackendCanSerialize backend [Char]) => IsString (QGenExpr context backend s Text) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

fromString :: String -> QGenExpr context backend s Text #

ContextRewritable (QGenExpr old syntax s a) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Associated Types

type WithRewrittenContext (QGenExpr old syntax s a) ctxt :: Type Source #

Methods

rewriteContext :: Proxy ctxt -> QGenExpr old syntax s a -> WithRewrittenContext (QGenExpr old syntax s a) ctxt Source #

(BeamSqlBackendCanSerialize be a, BeamSqlBackend be) => SqlValable (QGenExpr ctxt be s a) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

val_ :: HaskellLiteralForQExpr (QGenExpr ctxt be s a) -> QGenExpr ctxt be s a Source #

type WithRewrittenThread s s' (tbl (Nullable (QGenExpr ctxt syntax s))) Source # 
Instance details

Defined in Database.Beam.Query.Internal

type WithRewrittenThread s s' (tbl (Nullable (QGenExpr ctxt syntax s))) = tbl (Nullable (QGenExpr ctxt syntax s'))
type WithRewrittenThread s s' (tbl (QGenExpr ctxt syntax s)) Source # 
Instance details

Defined in Database.Beam.Query.Internal

type WithRewrittenThread s s' (tbl (QGenExpr ctxt syntax s)) = tbl (QGenExpr ctxt syntax s')
type WithRewrittenThread s s' (QGenExpr ctxt syntax s a) Source # 
Instance details

Defined in Database.Beam.Query.Internal

type WithRewrittenThread s s' (QGenExpr ctxt syntax s a) = QGenExpr ctxt syntax s' a
type Retag tag (QGenExpr ctxt expr s t) Source # 
Instance details

Defined in Database.Beam.Query.Internal

type Retag tag (QGenExpr ctxt expr s t) = Columnar (tag (QGenExpr ctxt expr s)) t
type QExprToField (table (Nullable (QGenExpr context syntax s))) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToField (table (Nullable (QGenExpr context syntax s))) = table (Nullable (QField s))
type QExprToField (table (QGenExpr context syntax s)) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToField (table (QGenExpr context syntax s)) = table (QField s)
type QExprToIdentity (table (QGenExpr context syntax s)) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToIdentity (table (QGenExpr context syntax s)) = table Identity
type HaskellLiteralForQExpr (table (QGenExpr context be s)) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

type HaskellLiteralForQExpr (table (QGenExpr context be s)) = table Identity
type WithRewrittenContext (tbl (Nullable (QGenExpr old syntax s))) ctxt Source # 
Instance details

Defined in Database.Beam.Query.Internal

type WithRewrittenContext (tbl (Nullable (QGenExpr old syntax s))) ctxt = tbl (Nullable (QGenExpr ctxt syntax s))
type WithRewrittenContext (tbl (QGenExpr old syntax s)) ctxt Source # 
Instance details

Defined in Database.Beam.Query.Internal

type WithRewrittenContext (tbl (QGenExpr old syntax s)) ctxt = tbl (QGenExpr ctxt syntax s)
type QExprToField (QGenExpr ctxt syntax s a) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToField (QGenExpr ctxt syntax s a) = QField s a
type QExprToIdentity (QGenExpr context syntax s a) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToIdentity (QGenExpr context syntax s a) = a
type HaskellLiteralForQExpr (QGenExpr context be s a) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

type HaskellLiteralForQExpr (QGenExpr context be s a) = a
type WithRewrittenContext (QGenExpr old syntax s a) ctxt Source # 
Instance details

Defined in Database.Beam.Query.Internal

type WithRewrittenContext (QGenExpr old syntax s a) ctxt = QGenExpr ctxt syntax s a

data Q be (db :: (* -> *) -> *) s a Source #

The type of queries over the database db returning results of type a. The s argument is a threading argument meant to restrict cross-usage of QGenExprs. syntax represents the SQL syntax that this query is building.

Instances
Monad (Q be db s) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

(>>=) :: Q be db s a -> (a -> Q be db s b) -> Q be db s b #

(>>) :: Q be db s a -> Q be db s b -> Q be db s b #

return :: a -> Q be db s a #

fail :: String -> Q be db s a #

Functor (Q be db s) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

fmap :: (a -> b) -> Q be db s a -> Q be db s b #

(<$) :: a -> Q be db s b -> Q be db s a #

Applicative (Q be db s) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

pure :: a -> Q be db s a #

(<*>) :: Q be db s (a -> b) -> Q be db s a -> Q be db s b #

liftA2 :: (a -> b -> c) -> Q be db s a -> Q be db s b -> Q be db s c #

(*>) :: Q be db s a -> Q be db s b -> Q be db s b #

(<*) :: Q be db s a -> Q be db s b -> Q be db s a #

type family QExprToField x Source #

Instances
type QExprToField () Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToField () = ()
type QExprToField (table (Nullable (QGenExpr context syntax s))) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToField (table (Nullable (QGenExpr context syntax s))) = table (Nullable (QField s))
type QExprToField (table (QGenExpr context syntax s)) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToField (table (QGenExpr context syntax s)) = table (QField s)
type QExprToField (a, b) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToField (Vector n a) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToField (a, b, c) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToField (a, b, c, d) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToField (QGenExpr ctxt syntax s a) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToField (QGenExpr ctxt syntax s a) = QField s a
type QExprToField (a, b, c, d, e) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToField (a, b, c, d, e, f) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToField (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToField (a, b, c, d, e, f, g, h) Source # 
Instance details

Defined in Database.Beam.Query.Types

type family QExprToIdentity x Source #

Instances
type QExprToIdentity () Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToIdentity () = ()
type QExprToIdentity (table (Nullable c)) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToIdentity (table (Nullable c)) = Maybe (QExprToIdentity (table c))
type QExprToIdentity (table (QGenExpr context syntax s)) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToIdentity (table (QGenExpr context syntax s)) = table Identity
type QExprToIdentity (a, b) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToIdentity (Vector n a) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToIdentity (a, b, c) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToIdentity (a, b, c, d) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToIdentity (QGenExpr context syntax s a) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToIdentity (QGenExpr context syntax s a) = a
type QExprToIdentity (a, b, c, d, e) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToIdentity (a, b, c, d, e, f) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToIdentity (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Database.Beam.Query.Types

type QExprToIdentity (a, b, c, d, e, f, g, h) Source # 
Instance details

Defined in Database.Beam.Query.Types

Query expression contexts

A context is a type-level value that signifies where an expression can be used. For example, QGenExpr corresponds to QGenExprs that result in values. In reality, QGenExpr is really QGenExpr parameterized over the QValueContext. Similarly, QAgg represents expressions that contain aggregates, but it is just QGenExpr parameterized over QAggregateContext

data QAggregateContext Source #

Instances
type ContextName QAggregateContext Source # 
Instance details

Defined in Database.Beam.Query.Internal

type ContextName QAggregateContext = "an aggregate"

data QGroupingContext Source #

Instances
Beamable tbl => QGroupable (tbl (Nullable (QExpr be s))) (tbl (Nullable (QGroupExpr be s))) Source #

group_ for any Beamable type. Adds every field in the type to the grouping key. This is the equivalent of including the grouping expression of each field in the type as part of the aggregate projection

Instance details

Defined in Database.Beam.Query.Aggregate

Methods

group_ :: tbl (Nullable (QExpr be s)) -> tbl (Nullable (QGroupExpr be s)) Source #

Beamable tbl => QGroupable (tbl (QExpr be s)) (tbl (QGroupExpr be s)) Source #

group_ for any Beamable type. Adds every field in the type to the grouping key. This is the equivalent of including the grouping expression of each field in the type as part of the aggregate projection

Instance details

Defined in Database.Beam.Query.Aggregate

Methods

group_ :: tbl (QExpr be s) -> tbl (QGroupExpr be s) Source #

QGroupable (QExpr be s a) (QGroupExpr be s a) Source #

group_ for simple value expressions.

Instance details

Defined in Database.Beam.Query.Aggregate

Methods

group_ :: QExpr be s a -> QGroupExpr be s a Source #

type ContextName QGroupingContext Source # 
Instance details

Defined in Database.Beam.Query.Internal

type ContextName QGroupingContext = "an aggregate grouping"

data QValueContext Source #

Instances
(Table t, BeamSqlBackend be) => SqlJustable (t (QExpr be s)) (t (Nullable (QExpr be s))) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

just_ :: t (QExpr be s) -> t (Nullable (QExpr be s)) Source #

nothing_ :: t (Nullable (QExpr be s)) Source #

Beamable tbl => QGroupable (tbl (Nullable (QExpr be s))) (tbl (Nullable (QGroupExpr be s))) Source #

group_ for any Beamable type. Adds every field in the type to the grouping key. This is the equivalent of including the grouping expression of each field in the type as part of the aggregate projection

Instance details

Defined in Database.Beam.Query.Aggregate

Methods

group_ :: tbl (Nullable (QExpr be s)) -> tbl (Nullable (QGroupExpr be s)) Source #

Beamable tbl => QGroupable (tbl (QExpr be s)) (tbl (QGroupExpr be s)) Source #

group_ for any Beamable type. Adds every field in the type to the grouping key. This is the equivalent of including the grouping expression of each field in the type as part of the aggregate projection

Instance details

Defined in Database.Beam.Query.Aggregate

Methods

group_ :: tbl (QExpr be s) -> tbl (QGroupExpr be s) Source #

(Table t, BeamSqlBackend be) => SqlJustable (PrimaryKey t (QExpr be s)) (PrimaryKey t (Nullable (QExpr be s))) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

just_ :: PrimaryKey t (QExpr be s) -> PrimaryKey t (Nullable (QExpr be s)) Source #

nothing_ :: PrimaryKey t (Nullable (QExpr be s)) Source #

BeamSqlBackend be => SqlJustable (QExpr be s a) (QExpr be s (Maybe a)) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

just_ :: QExpr be s a -> QExpr be s (Maybe a) Source #

nothing_ :: QExpr be s (Maybe a) Source #

QGroupable (QExpr be s a) (QGroupExpr be s a) Source #

group_ for simple value expressions.

Instance details

Defined in Database.Beam.Query.Aggregate

Methods

group_ :: QExpr be s a -> QGroupExpr be s a Source #

type ContextName QValueContext Source # 
Instance details

Defined in Database.Beam.Query.Internal

type ContextName QValueContext = "a value"

data QWindowingContext Source #

Instances
type ContextName QWindowingContext Source # 
Instance details

Defined in Database.Beam.Query.Internal

type ContextName QWindowingContext = "a window expression"

type QGenExprTable ctxt be s tbl = tbl (QGenExpr ctxt be s) Source #

A version of the table where each field is a QGenExpr

type QExprTable be s tbl = QGenExprTable QValueContext be s tbl Source #

data QAssignment be s Source #

Instances
Semigroup (QAssignment be s) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

(<>) :: QAssignment be s -> QAssignment be s -> QAssignment be s #

sconcat :: NonEmpty (QAssignment be s) -> QAssignment be s #

stimes :: Integral b => b -> QAssignment be s -> QAssignment be s #

Monoid (QAssignment be s) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

mempty :: QAssignment be s #

mappend :: QAssignment be s -> QAssignment be s -> QAssignment be s #

mconcat :: [QAssignment be s] -> QAssignment be s #

data QField s ty Source #

Instances
Beamable t => ProjectibleWithPredicate AnyType () Text (t (Nullable (QField s))) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

project' :: Monad m => Proxy AnyType -> Proxy ((), Text) -> (forall context. AnyType context => Proxy context -> Proxy () -> Text -> m Text) -> t (Nullable (QField s)) -> m (t (Nullable (QField s))) Source #

projectSkeleton' :: Monad m => Proxy AnyType -> Proxy ((), Text) -> (forall context. AnyType context => Proxy context -> Proxy () -> m Text) -> m (t (Nullable (QField s))) Source #

Beamable t => ProjectibleWithPredicate AnyType () Text (t (QField s)) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

project' :: Monad m => Proxy AnyType -> Proxy ((), Text) -> (forall context. AnyType context => Proxy context -> Proxy () -> Text -> m Text) -> t (QField s) -> m (t (QField s)) Source #

projectSkeleton' :: Monad m => Proxy AnyType -> Proxy ((), Text) -> (forall context. AnyType context => Proxy context -> Proxy () -> m Text) -> m (t (QField s)) Source #

ProjectibleWithPredicate AnyType () Text (QField s a) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

project' :: Monad m => Proxy AnyType -> Proxy ((), Text) -> (forall context. AnyType context => Proxy context -> Proxy () -> Text -> m Text) -> QField s a -> m (QField s a) Source #

projectSkeleton' :: Monad m => Proxy AnyType -> Proxy ((), Text) -> (forall context. AnyType context => Proxy context -> Proxy () -> m Text) -> m (QField s a) Source #

Eq (QField s ty) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

(==) :: QField s ty -> QField s ty -> Bool #

(/=) :: QField s ty -> QField s ty -> Bool #

Ord (QField s ty) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

compare :: QField s ty -> QField s ty -> Ordering #

(<) :: QField s ty -> QField s ty -> Bool #

(<=) :: QField s ty -> QField s ty -> Bool #

(>) :: QField s ty -> QField s ty -> Bool #

(>=) :: QField s ty -> QField s ty -> Bool #

max :: QField s ty -> QField s ty -> QField s ty #

min :: QField s ty -> QField s ty -> QField s ty #

Show (QField s ty) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

showsPrec :: Int -> QField s ty -> ShowS #

show :: QField s ty -> String #

showList :: [QField s ty] -> ShowS #

data QFieldAssignment be tbl a Source #

Various SQL functions and constructs

coalesce_ :: BeamSqlBackend be => [QGenExpr ctxt be s (Maybe a)] -> QGenExpr ctxt be s a -> QGenExpr ctxt be s a Source #

SQL COALESCE support

fromMaybe_ :: BeamSqlBackend be => QGenExpr ctxt be s a -> QGenExpr ctxt be s (Maybe a) -> QGenExpr ctxt be s a Source #

Converta a Maybe value to a concrete value, by suppling a default

position_ :: (BeamSqlBackendIsString be text, BeamSqlBackend be, Integral b) => QExpr be s text -> QExpr be s text -> QExpr be s b Source #

SQL POSITION(.. IN ..) function

charLength_ :: (BeamSqlBackend be, BeamSqlBackendIsString be text) => QGenExpr context be s text -> QGenExpr context be s Int Source #

SQL CHAR_LENGTH function

octetLength_ :: (BeamSqlBackend be, BeamSqlBackendIsString be text) => QGenExpr context be s text -> QGenExpr context be s Int Source #

SQL OCTET_LENGTH function

bitLength_ :: BeamSqlBackend be => QGenExpr context be s SqlBitString -> QGenExpr context be s Int Source #

SQL BIT_LENGTH function

currentTimestamp_ :: BeamSqlBackend be => QGenExpr ctxt be s LocalTime Source #

SQL CURRENT_TIMESTAMP function

lower_ :: (BeamSqlBackendIsString be text, BeamSqlBackend be) => QGenExpr context be s text -> QGenExpr context be s text Source #

SQL LOWER function

upper_ :: (BeamSqlBackendIsString be text, BeamSqlBackend be) => QGenExpr context be s text -> QGenExpr context be s text Source #

SQL UPPER function

trim_ :: (BeamSqlBackendIsString be text, BeamSqlBackend be) => QGenExpr context be s text -> QGenExpr context be s text Source #

SQL TRIM function

IF-THEN-ELSE support

if_ :: BeamSqlBackend be => [QIfCond context be s a] -> QIfElse context be s a -> QGenExpr context be s a Source #

then_ :: QGenExpr context be s Bool -> QGenExpr context be s a -> QIfCond context be s a Source #

else_ :: QGenExpr context be s a -> QIfElse context be s a Source #

then_' :: QGenExpr context be s SqlBool -> QGenExpr context be s a -> QIfCond context be s a Source #

SQL UPDATE assignments

(<-.) :: SqlUpdatable be s lhs rhs => lhs -> rhs -> QAssignment be s infix 4 Source #

Update a QField or Beamable type containing QFields with the given QGenExpr or Beamable type containing QGenExpr

current_ :: BeamSqlBackend be => QField s ty -> QExpr be s ty Source #

Extract an expression representing the current (non-UPDATEd) value of a QField

Project Haskell values to QGenExprs

type family HaskellLiteralForQExpr x = a Source #

Instances
type HaskellLiteralForQExpr (table (QGenExpr context be s)) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

type HaskellLiteralForQExpr (table (QGenExpr context be s)) = table Identity
type HaskellLiteralForQExpr (table (Nullable f)) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

type HaskellLiteralForQExpr (QGenExpr context be s a) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

type HaskellLiteralForQExpr (QGenExpr context be s a) = a

class SqlValable a where Source #

Instances
(Beamable table, BeamSqlBackend be, FieldsFulfillConstraintNullable (BeamSqlBackendCanSerialize be) table) => SqlValable (table (Nullable (QGenExpr ctxt be s))) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

val_ :: HaskellLiteralForQExpr (table (Nullable (QGenExpr ctxt be s))) -> table (Nullable (QGenExpr ctxt be s)) Source #

(Beamable table, BeamSqlBackend be, FieldsFulfillConstraint (BeamSqlBackendCanSerialize be) table) => SqlValable (table (QGenExpr ctxt be s)) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

val_ :: HaskellLiteralForQExpr (table (QGenExpr ctxt be s)) -> table (QGenExpr ctxt be s) Source #

(BeamSqlBackendCanSerialize be a, BeamSqlBackend be) => SqlValable (QGenExpr ctxt be s a) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

val_ :: HaskellLiteralForQExpr (QGenExpr ctxt be s a) -> QGenExpr ctxt be s a Source #

default_ :: BeamSqlBackend be => QGenExpr ctxt be s a Source #

General query combinators

all_ :: (Database be db, BeamSqlBackend be) => DatabaseEntity be db (TableEntity table) -> Q be db s (table (QExpr be s)) Source #

Introduce all entries of a table into the Q monad

values_ :: forall be db s a. (Projectible be a, BeamSqlBackend be) => [a] -> Q be db s a Source #

allFromView_ :: (Database be db, Beamable table, BeamSqlBackend be) => DatabaseEntity be db (ViewEntity table) -> Q be db s (table (QExpr be s)) Source #

Introduce all entries of a view into the Q monad

join_ :: (Database be db, Table table, BeamSqlBackend be) => DatabaseEntity be db (TableEntity table) -> (table (QExpr be s) -> QExpr be s Bool) -> Q be db s (table (QExpr be s)) Source #

Introduce all entries of a table into the Q monad based on the given QExpr. The join condition is expected to return a Bool. For a version that takes SqlBool (a possibly UNKNOWN boolean, that maps more closely to the SQL standard), see join_'.

join_' :: (Database be db, Table table, BeamSqlBackend be) => DatabaseEntity be db (TableEntity table) -> (table (QExpr be s) -> QExpr be s SqlBool) -> Q be db s (table (QExpr be s)) Source #

Like join_, but accepting an ON condition that returns SqlBool

guard_ :: forall be db s. BeamSqlBackend be => QExpr be s Bool -> Q be db s () Source #

Only allow results for which the QGenExpr yields True. For a version that operates over possibly NULL SqlBools, see guard_'.

guard_' :: forall be db s. BeamSqlBackend be => QExpr be s SqlBool -> Q be db s () Source #

Only allow results for which the QGenExpr yields TRUE.

This function operates over SqlBool, which are like haskell Bools, except for the special UNKNOWN value that occurs when comparisons include NULL. For a version that operates over known non-NULL booleans, see guard_.

filter_ :: forall r be db s. BeamSqlBackend be => (r -> QExpr be s Bool) -> Q be db s r -> Q be db s r Source #

Synonym for clause >>= x -> guard_ (mkExpr x)>> pure x. Use filter_' for comparisons with SqlBool

filter_' :: forall r be db s. BeamSqlBackend be => (r -> QExpr be s SqlBool) -> Q be db s r -> Q be db s r Source #

Synonym for clause >>= x -> guard_' (mkExpr x)>> pure x. Use filter_ for comparisons with Bool

related_ :: forall be db rel s. (Database be db, Table rel, BeamSqlBackend be, HasTableEquality be (PrimaryKey rel)) => DatabaseEntity be db (TableEntity rel) -> PrimaryKey rel (QExpr be s) -> Q be db s (rel (QExpr be s)) Source #

Introduce all entries of the given table which are referenced by the given PrimaryKey

relatedBy_ :: forall be db rel s. (Database be db, Table rel, BeamSqlBackend be) => DatabaseEntity be db (TableEntity rel) -> (rel (QExpr be s) -> QExpr be s Bool) -> Q be db s (rel (QExpr be s)) Source #

Introduce all entries of the given table which for which the expression (which can depend on the queried table returns true)

relatedBy_' :: forall be db rel s. (Database be db, Table rel, BeamSqlBackend be) => DatabaseEntity be db (TableEntity rel) -> (rel (QExpr be s) -> QExpr be s SqlBool) -> Q be db s (rel (QExpr be s)) Source #

Introduce all entries of the given table which for which the expression (which can depend on the queried table returns true)

leftJoin_ :: forall s r be db. (BeamSqlBackend be, Projectible be r, ThreadRewritable (QNested s) r, Retaggable (QExpr be s) (WithRewrittenThread (QNested s) s r)) => Q be db (QNested s) r -> (WithRewrittenThread (QNested s) s r -> QExpr be s Bool) -> Q be db s (Retag Nullable (WithRewrittenThread (QNested s) s r)) Source #

Introduce a table using a left join. The ON clause is required here.Because this is not an inner join, the resulting table is made nullable. This means that each field that would normally have type 'QExpr x' will now have type 'QExpr (Maybe x)'.

The ON condition given must return Bool. For a version that accepts an ON condition returning SqlBool, see leftJoin_'.

leftJoin_' :: forall s r be db. (BeamSqlBackend be, Projectible be r, ThreadRewritable (QNested s) r, Retaggable (QExpr be s) (WithRewrittenThread (QNested s) s r)) => Q be db (QNested s) r -> (WithRewrittenThread (QNested s) s r -> QExpr be s SqlBool) -> Q be db s (Retag Nullable (WithRewrittenThread (QNested s) s r)) Source #

Like leftJoin_, but accepts an ON clause returning SqlBool.

perhaps_ :: forall s r be db. (Projectible be r, BeamSqlBackend be, ThreadRewritable (QNested s) r, Retaggable (QExpr be s) (WithRewrittenThread (QNested s) s r)) => Q be db (QNested s) r -> Q be db s (Retag Nullable (WithRewrittenThread (QNested s) s r)) Source #

Introduce a table using a left join with no ON clause. Because this is not an inner join, the resulting table is made nullable. This means that each field that would normally have type 'QExpr x' will now have type 'QExpr (Maybe x)'.

outerJoin_ :: forall s a b be db. (BeamSqlBackend be, BeamSqlBackendSupportsOuterJoin be, Projectible be a, Projectible be b, ThreadRewritable (QNested s) a, ThreadRewritable (QNested s) b, Retaggable (QExpr be s) (WithRewrittenThread (QNested s) s a), Retaggable (QExpr be s) (WithRewrittenThread (QNested s) s b)) => Q be db (QNested s) a -> Q be db (QNested s) b -> ((WithRewrittenThread (QNested s) s a, WithRewrittenThread (QNested s) s b) -> QExpr be s Bool) -> Q be db s (Retag Nullable (WithRewrittenThread (QNested s) s a), Retag Nullable (WithRewrittenThread (QNested s) s b)) Source #

Outer join. every row of each table, returning NULL for any row of either table for which the join condition finds no related rows.

This expects a join expression returning Bool, for a version that accepts a SqlBool (a possibly UNKNOWN boolean, that maps more closely to the SQL standard), see outerJoin_'

outerJoin_' :: forall s a b be db. (BeamSqlBackend be, BeamSqlBackendSupportsOuterJoin be, Projectible be a, Projectible be b, ThreadRewritable (QNested s) a, ThreadRewritable (QNested s) b, Retaggable (QExpr be s) (WithRewrittenThread (QNested s) s a), Retaggable (QExpr be s) (WithRewrittenThread (QNested s) s b)) => Q be db (QNested s) a -> Q be db (QNested s) b -> ((WithRewrittenThread (QNested s) s a, WithRewrittenThread (QNested s) s b) -> QExpr be s SqlBool) -> Q be db s (Retag Nullable (WithRewrittenThread (QNested s) s a), Retag Nullable (WithRewrittenThread (QNested s) s b)) Source #

Like outerJoin_, but accepting SqlBool. Pairs of rows for which the join condition is unknown are considered to be unrelated, by SQL compliant databases at least.

subselect_ :: forall s r be db. (ThreadRewritable (QNested s) r, Projectible be r) => Q be db (QNested s) r -> Q be db s (WithRewrittenThread (QNested s) s r) Source #

references_ :: (Table t, BeamSqlBackend be, HasTableEquality be (PrimaryKey t)) => PrimaryKey t (QGenExpr ctxt be s) -> t (QGenExpr ctxt be s) -> QGenExpr ctxt be s Bool Source #

Generate an appropriate boolean QGenExpr comparing the given foreign key to the given table. Useful for creating join conditions.

nub_ :: (BeamSqlBackend be, Projectible be r) => Q be db s r -> Q be db s r Source #

Only return distinct values from a query

class SqlJustable a b | b -> a where Source #

Type class for things that can be nullable. This includes 'QExpr (Maybe a)', 'tbl (Nullable QExpr)', and 'PrimaryKey tbl (Nullable QExpr)'

Methods

just_ :: a -> b Source #

Given something of type 'QExpr a', 'tbl QExpr', or 'PrimaryKey tbl QExpr', turn it into a 'QExpr (Maybe a)', 'tbl (Nullable QExpr)', or 'PrimaryKey t (Nullable QExpr)' respectively that contains the same values.

nothing_ :: b Source #

Return either a 'QExpr (Maybe x)' representing Nothing or a nullable Table or PrimaryKey filled with Nothing.

Instances
Table t => SqlJustable (t Identity) (t (Nullable Identity)) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

(Table t, BeamSqlBackend be) => SqlJustable (t (QExpr be s)) (t (Nullable (QExpr be s))) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

just_ :: t (QExpr be s) -> t (Nullable (QExpr be s)) Source #

nothing_ :: t (Nullable (QExpr be s)) Source #

Table t => SqlJustable (PrimaryKey t Identity) (PrimaryKey t (Nullable Identity)) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

(Table t, BeamSqlBackend be) => SqlJustable (PrimaryKey t (QExpr be s)) (PrimaryKey t (Nullable (QExpr be s))) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

just_ :: PrimaryKey t (QExpr be s) -> PrimaryKey t (Nullable (QExpr be s)) Source #

nothing_ :: PrimaryKey t (Nullable (QExpr be s)) Source #

BeamSqlBackend be => SqlJustable (QExpr be s a) (QExpr be s (Maybe a)) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

just_ :: QExpr be s a -> QExpr be s (Maybe a) Source #

nothing_ :: QExpr be s (Maybe a) Source #

class BeamSqlBackend be => SqlDeconstructMaybe be a nonNullA s | a s -> be, a -> nonNullA, a -> s, nonNullA -> s where Source #

Type class for anything which can be checked for null-ness. This includes 'QExpr (Maybe a)' as well as Tables or PrimaryKeys over 'Nullable QExpr'.

Methods

isJust_ :: a -> QGenExpr ctxt be s Bool Source #

Returns a QGenExpr that evaluates to true when the first argument is not null

isNothing_ :: a -> QGenExpr ctxt be s Bool Source #

Returns a QGenExpr that evaluates to true when the first argument is null

maybe_ :: QGenExpr ctxt be s y -> (nonNullA -> QGenExpr ctxt be s y) -> a -> QGenExpr ctxt be s y Source #

Given an object (third argument) which may or may not be null, return the default value if null (first argument), or transform the value that could be null to yield the result of the expression (second argument)

Instances
(BeamSqlBackend be, Beamable t) => SqlDeconstructMaybe be (t (Nullable (QGenExpr ctxt be s))) (t (QGenExpr ctxt be s)) s Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

isJust_ :: t (Nullable (QGenExpr ctxt be s)) -> QGenExpr ctxt0 be s Bool Source #

isNothing_ :: t (Nullable (QGenExpr ctxt be s)) -> QGenExpr ctxt0 be s Bool Source #

maybe_ :: QGenExpr ctxt0 be s y -> (t (QGenExpr ctxt be s) -> QGenExpr ctxt0 be s y) -> t (Nullable (QGenExpr ctxt be s)) -> QGenExpr ctxt0 be s y Source #

BeamSqlBackend be => SqlDeconstructMaybe be (QGenExpr ctxt be s (Maybe x)) (QGenExpr ctxt be s x) s Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

isJust_ :: QGenExpr ctxt be s (Maybe x) -> QGenExpr ctxt0 be s Bool Source #

isNothing_ :: QGenExpr ctxt be s (Maybe x) -> QGenExpr ctxt0 be s Bool Source #

maybe_ :: QGenExpr ctxt0 be s y -> (QGenExpr ctxt be s x -> QGenExpr ctxt0 be s y) -> QGenExpr ctxt be s (Maybe x) -> QGenExpr ctxt0 be s y Source #

class SqlOrderable be a | a -> be Source #

Minimal complete definition

makeSQLOrdering

Instances
SqlOrderable be a => SqlOrderable be [a] Source # 
Instance details

Defined in Database.Beam.Query.Combinators

(SqlOrderable be a, SqlOrderable be b) => SqlOrderable be (a, b) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

(SqlOrderable be a, SqlOrderable be b, SqlOrderable be c) => SqlOrderable be (a, b, c) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

SqlOrderable be (QOrd be s a) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

(SqlOrderable be a, SqlOrderable be b, SqlOrderable be c, SqlOrderable be d) => SqlOrderable be (a, b, c, d) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

makeSQLOrdering :: Proxy be -> (a, b, c, d) -> [WithExprContext (BeamSqlBackendOrderingSyntax be)]

(SqlOrderable be a, SqlOrderable be b, SqlOrderable be c, SqlOrderable be d, SqlOrderable be e) => SqlOrderable be (a, b, c, d, e) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

makeSQLOrdering :: Proxy be -> (a, b, c, d, e) -> [WithExprContext (BeamSqlBackendOrderingSyntax be)]

(SqlOrderable be a, SqlOrderable be b, SqlOrderable be c, SqlOrderable be d, SqlOrderable be e, SqlOrderable be f) => SqlOrderable be (a, b, c, d, e, f) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

makeSQLOrdering :: Proxy be -> (a, b, c, d, e, f) -> [WithExprContext (BeamSqlBackendOrderingSyntax be)]

(SqlOrderable be a, SqlOrderable be b, SqlOrderable be c, SqlOrderable be d, SqlOrderable be e, SqlOrderable be f, SqlOrderable be g) => SqlOrderable be (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

makeSQLOrdering :: Proxy be -> (a, b, c, d, e, f, g) -> [WithExprContext (BeamSqlBackendOrderingSyntax be)]

(SqlOrderable be a, SqlOrderable be b, SqlOrderable be c, SqlOrderable be d, SqlOrderable be e, SqlOrderable be f, SqlOrderable be g, SqlOrderable be h) => SqlOrderable be (a, b, c, d, e, f, g, h) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

makeSQLOrdering :: Proxy be -> (a, b, c, d, e, f, g, h) -> [WithExprContext (BeamSqlBackendOrderingSyntax be)]

data QIfCond context be s a Source #

data QIfElse context be s a Source #

(<|>.) :: (SqlJustable a (QGenExpr ctxt syntax s y), SqlDeconstructMaybe syntax (QGenExpr ctxt syntax s y) a s) => QGenExpr ctxt syntax s y -> QGenExpr ctxt syntax s y -> QGenExpr ctxt syntax s y infixl 3 Source #

limit_ :: forall s a be db. (Projectible be a, ThreadRewritable (QNested s) a) => Integer -> Q be db (QNested s) a -> Q be db s (WithRewrittenThread (QNested s) s a) Source #

Limit the number of results returned by a query.

offset_ :: forall s a be db. (Projectible be a, ThreadRewritable (QNested s) a) => Integer -> Q be db (QNested s) a -> Q be db s (WithRewrittenThread (QNested s) s a) Source #

Drop the first offset' results.

as_ :: forall a ctxt be s. QGenExpr ctxt be s a -> QGenExpr ctxt be s a Source #

Convenience function that allows you to use type applications to specify the result of a QGenExpr.

Useful to disambiguate the types of QGenExprs without having to provide a complete type signature. As an example, the countAll_ aggregate can return a result of any Integral type. Without further constraints, the type is ambiguous. You can use as_ to disambiguate the return type.

For example, this is ambiguous

aggregate_ (\_ -> countAll_) ..

But this is not

aggregate_ (\_ -> as_ @Int countAll_) ..

Subqueries

exists_ :: (BeamSqlBackend be, HasQBuilder be, Projectible be a) => Q be db s a -> QExpr be s Bool Source #

Use the SQL EXISTS operator to determine if the given query returns any results

unique_ :: (BeamSqlBackend be, HasQBuilder be, Projectible be a) => Q be db s a -> QExpr be s Bool Source #

Use the SQL UNIQUE operator to determine if the given query produces a unique result

distinct_ :: (BeamSqlBackend be, BeamSql99ExpressionBackend be, HasQBuilder be, Projectible be a) => Q be db s a -> QExpr be s Bool Source #

Use the SQL99 DISTINCT operator to determine if the given query produces a distinct result

subquery_ :: (BeamSqlBackend be, HasQBuilder be, Projectible be (QExpr be s a)) => Q be db s (QExpr be s a) -> QGenExpr ctxt be s a Source #

Project the (presumably) singular result of the given query as an expression

Set operations

Q values can be combined using a variety of set operations. See the manual section.

union_ :: forall be db s a. (BeamSqlBackend be, Projectible be a, ThreadRewritable (QNested s) a) => Q be db (QNested s) a -> Q be db (QNested s) a -> Q be db s (WithRewrittenThread (QNested s) s a) Source #

SQL UNION operator

unionAll_ :: forall be db s a. (BeamSqlBackend be, Projectible be a, ThreadRewritable (QNested s) a) => Q be db (QNested s) a -> Q be db (QNested s) a -> Q be db s (WithRewrittenThread (QNested s) s a) Source #

SQL UNION ALL operator

intersect_ :: forall be db s a. (BeamSqlBackend be, Projectible be a, ThreadRewritable (QNested s) a) => Q be db (QNested s) a -> Q be db (QNested s) a -> Q be db s (WithRewrittenThread (QNested s) s a) Source #

SQL INTERSECT operator

intersectAll_ :: forall be db s a. (BeamSqlBackend be, Projectible be a, ThreadRewritable (QNested s) a) => Q be db (QNested s) a -> Q be db (QNested s) a -> Q be db s (WithRewrittenThread (QNested s) s a) Source #

SQL INTERSECT ALL operator

except_ :: forall be db s a. (BeamSqlBackend be, Projectible be a, ThreadRewritable (QNested s) a) => Q be db (QNested s) a -> Q be db (QNested s) a -> Q be db s (WithRewrittenThread (QNested s) s a) Source #

SQL EXCEPT operator

exceptAll_ :: forall be db s a. (BeamSqlBackend be, Projectible be a, ThreadRewritable (QNested s) a) => Q be db (QNested s) a -> Q be db (QNested s) a -> Q be db s (WithRewrittenThread (QNested s) s a) Source #

SQL EXCEPT ALL operator

Window functions

See the corresponding manual section for more.

over_ :: BeamSql2003ExpressionBackend be => QAgg be s a -> QWindow be s -> QWindowExpr be s a Source #

Produce a window expression given an aggregate function and a window.

frame_ Source #

Arguments

:: (BeamSql2003ExpressionBackend be, SqlOrderable be ordering, Projectible be partition) 
=> Maybe partition

PARTITION BY

-> Maybe ordering

ORDER BY

-> QFrameBounds be

RANGE / ROWS

-> QWindow be s 

Specify a window frame with all the options

partitionBy_ :: partition -> Maybe partition Source #

orderPartitionBy_ :: partition -> Maybe partition Source #

withWindow_ Source #

Arguments

:: (ProjectibleWithPredicate WindowFrameContext be (WithExprContext (BeamSqlBackendWindowFrameSyntax' be)) window, Projectible be r, Projectible be a, ContextRewritable a, ThreadRewritable (QNested s) (WithRewrittenContext a QValueContext)) 
=> (r -> window)

Window builder function

-> (r -> window -> a)

Projection builder function. Has access to the windows generated above

-> Q be db (QNested s) r

Query to window over

-> Q be db s (WithRewrittenThread (QNested s) s (WithRewrittenContext a QValueContext)) 

Compute a query over windows.

The first function builds window frames using the frame_, partitionBy_, etc functions. The return type can be a single frame, tuples of frame, or any arbitrarily nested tuple of the above. Instances up to 8-tuples are provided.

The second function builds the resulting projection using the result of the subquery as well as the window frames built in the first function. In this function, window expressions can be included in the output using the over_ function.

Ordering primitives

orderBy_ :: forall s a ordering be db. (Projectible be a, SqlOrderable be ordering, ThreadRewritable (QNested s) a) => (a -> ordering) -> Q be db (QNested s) a -> Q be db s (WithRewrittenThread (QNested s) s a) Source #

Order by the given expressions. The return type of the ordering key should either be the result of asc_ or desc_ (or another ordering QOrd generated by a backend-specific ordering) or an (possibly nested) tuple of results of the former.

The manual section has more information.

asc_ :: forall be s a. BeamSqlBackend be => QExpr be s a -> QOrd be s a Source #

Produce a QOrd corresponding to a SQL ASC ordering

desc_ :: forall be s a. BeamSqlBackend be => QExpr be s a -> QOrd be s a Source #

Produce a QOrd corresponding to a SQL DESC ordering

Various combinators corresponding to SQL extensions

T614 NTILE function

T615 LEAD and LAG function

lead1_ :: (BeamSqlBackend be, BeamSqlT615Backend be) => QExpr be s a -> QAgg be s a Source #

lag1_ :: (BeamSqlBackend be, BeamSqlT615Backend be) => QExpr be s a -> QAgg be s a Source #

lead_ :: (BeamSqlBackend be, BeamSqlT615Backend be) => QExpr be s a -> QExpr be s Int -> QAgg be s a Source #

lag_ :: (BeamSqlBackend be, BeamSqlT615Backend be) => QExpr be s a -> QExpr be s Int -> QAgg be s a Source #

leadWithDefault_ :: (BeamSqlBackend be, BeamSqlT615Backend be) => QExpr be s a -> QExpr be s Int -> QExpr be s a -> QAgg be s a Source #

lagWithDefault_ :: (BeamSqlBackend be, BeamSqlT615Backend be) => QExpr be s a -> QExpr be s Int -> QExpr be s a -> QAgg be s a Source #

T616 FIRST_VALUE and LAST_VALUE functions

T618 NTH_VALUE function

nthValue_ :: (BeamSqlBackend be, BeamSqlT618Backend be) => QExpr be s a -> QExpr be s Int -> QAgg be s a Source #

T621 Enhanced numeric functions

(**.) :: (Floating a, BeamSqlBackend be, BeamSqlT621Backend be) => QGenExpr ctxt be s a -> QGenExpr ctxt be s a -> QGenExpr ctxt be s a infixr 8 Source #

ln_ :: (Floating a, BeamSqlBackend be, BeamSqlT621Backend be) => QGenExpr ctxt be s a -> QGenExpr ctxt be s a Source #

exp_ :: (Floating a, BeamSqlBackend be, BeamSqlT621Backend be) => QGenExpr ctxt be s a -> QGenExpr ctxt be s a Source #

sqrt_ :: (Floating a, BeamSqlBackend be, BeamSqlT621Backend be) => QGenExpr ctxt be s a -> QGenExpr ctxt be s a Source #

ceiling_ :: (RealFrac a, Integral b, BeamSqlBackend be, BeamSqlT621Backend be) => QGenExpr ctxt be s a -> QGenExpr ctxt be s b Source #

floor_ :: (RealFrac a, Integral b, BeamSqlBackend be, BeamSqlT621Backend be) => QGenExpr ctxt be s a -> QGenExpr ctxt be s b Source #

stddevPop_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QAgg be s b Source #

varPop_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QAgg be s b Source #

varSamp_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QAgg be s b Source #

covarPop_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b Source #

covarSamp_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b Source #

corr_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b Source #

regrSlope_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b Source #

regrIntercept_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b Source #

regrCount_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b Source #

regrRSquared_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b Source #

regrAvgX_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b Source #

regrAvgY_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b Source #

regrSXX_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b Source #

regrSYY_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b Source #

regrSXY_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b Source #

Relationships

Many-to-many relationships

type ManyToMany be db left right = forall s. (BeamSqlBackend be, SqlEq (QExpr be s) (PrimaryKey left (QExpr be s)), SqlEq (QExpr be s) (PrimaryKey right (QExpr be s))) => Q be db s (left (QExpr be s)) -> Q be db s (right (QExpr be s)) -> Q be db s (left (QExpr be s), right (QExpr be s)) Source #

Convenience type to declare many-to-many relationships. See the manual section on relationships for more information

type ManyToManyThrough be db through left right = forall s. (BeamSqlBackend be, SqlEq (QExpr be s) (PrimaryKey left (QExpr be s)), SqlEq (QExpr be s) (PrimaryKey right (QExpr be s))) => Q be db s (left (QExpr be s)) -> Q be db s (right (QExpr be s)) -> Q be db s (through (QExpr be s), left (QExpr be s), right (QExpr be s)) Source #

Convenience type to declare many-to-many relationships with additional data. See the manual section on relationships for more information

manyToMany_ :: (Database be db, Table joinThrough, Table left, Table right, BeamSqlBackend be, SqlEq (QExpr be s) (PrimaryKey left (QExpr be s)), SqlEq (QExpr be s) (PrimaryKey right (QExpr be s))) => DatabaseEntity be db (TableEntity joinThrough) -> (joinThrough (QExpr be s) -> PrimaryKey left (QExpr be s)) -> (joinThrough (QExpr be s) -> PrimaryKey right (QExpr be s)) -> Q be db s (left (QExpr be s)) -> Q be db s (right (QExpr be s)) -> Q be db s (left (QExpr be s), right (QExpr be s)) Source #

Used to define many-to-many relationships without any additional data. Takes the join table and two key extraction functions from that table to the related tables. Also takes two Qs representing the table sources to relate.

See the manual for more indformation.

manyToManyPassthrough_ :: (Database be db, Table joinThrough, Table left, Table right, BeamSqlBackend be, SqlEq (QExpr be s) (PrimaryKey left (QExpr be s)), SqlEq (QExpr be s) (PrimaryKey right (QExpr be s))) => DatabaseEntity be db (TableEntity joinThrough) -> (joinThrough (QExpr be s) -> PrimaryKey left (QExpr be s)) -> (joinThrough (QExpr be s) -> PrimaryKey right (QExpr be s)) -> Q be db s (left (QExpr be s)) -> Q be db s (right (QExpr be s)) -> Q be db s (joinThrough (QExpr be s), left (QExpr be s), right (QExpr be s)) Source #

Used to define many-to-many relationships with additional data. Takes the join table and two key extraction functions from that table to the related tables. Also takes two Qs representing the table sources to relate.

See the manual for more indformation.

One-to-many relationships

type OneToMany be db s one many = (BeamSqlBackend be, BeamSqlBackendCanSerialize be Bool) => one (QExpr be s) -> Q be db s (many (QExpr be s)) Source #

Convenience type to declare one-to-many relationships. See the manual section on relationships for more information

type OneToManyOptional be db s tbl rel = (BeamSqlBackend be, BeamSqlBackendCanSerialize be Bool, BeamSqlBackendCanSerialize be SqlNull) => tbl (QExpr be s) -> Q be db s (rel (Nullable (QExpr be s))) Source #

Convenience type to declare one-to-many relationships with a nullable foreign key. See the manual section on relationships for more information

oneToMany_ Source #

Arguments

:: (Database be db, BeamSqlBackend be, HasTableEquality be (PrimaryKey tbl), Table tbl, Table rel) 
=> DatabaseEntity be db (TableEntity rel)

Table to fetch (many)

-> (rel (QExpr be s) -> PrimaryKey tbl (QExpr be s))

Foreign key

-> tbl (QExpr be s) 
-> Q be db s (rel (QExpr be s)) 

Used to define one-to-many (or one-to-one) relationships. Takes the table to fetch, a way to extract the foreign key from that table, and the table to relate to.

oneToManyOptional_ Source #

Arguments

:: (BeamSqlBackend be, Database be db, Table tbl, Table rel, HasTableEqualityNullable be (PrimaryKey tbl)) 
=> DatabaseEntity be db (TableEntity rel)

Table to fetch

-> (rel (QExpr be s) -> PrimaryKey tbl (Nullable (QExpr be s)))

Foreign key

-> tbl (QExpr be s) 
-> Q be db s (rel (Nullable (QExpr be s))) 

Used to define one-to-many (or one-to-one) relationships with a nullable foreign key. Takes the table to fetch, a way to extract the foreign key from that table, and the table to relate to.

One-to-one relationshships

type OneToOne be db s one many = OneToMany be db s one many Source #

Synonym of OneToMany. Useful for giving more meaningful types, when the relationship is meant to be one-to-one.

type OneToMaybe be db s tbl rel = OneToManyOptional be db s tbl rel Source #

Synonym of OneToManyOptional. Useful for giving more meaningful types, when the relationship is meant to be one-to-one.

oneToOne_ Source #

Arguments

:: (Database be db, BeamSqlBackend be, HasTableEquality be (PrimaryKey tbl), Table tbl, Table rel) 
=> DatabaseEntity be db (TableEntity rel)

Table to fetch (many)

-> (rel (QExpr be s) -> PrimaryKey tbl (QExpr be s))

Foreign key

-> tbl (QExpr be s) 
-> Q be db s (rel (QExpr be s)) 

Used to define one-to-many (or one-to-one) relationships. Takes the table to fetch, a way to extract the foreign key from that table, and the table to relate to.

oneToMaybe_ Source #

Arguments

:: (BeamSqlBackend be, Database be db, Table tbl, Table rel, HasTableEqualityNullable be (PrimaryKey tbl)) 
=> DatabaseEntity be db (TableEntity rel)

Table to fetch

-> (rel (QExpr be s) -> PrimaryKey tbl (Nullable (QExpr be s)))

Foreign key

-> tbl (QExpr be s) 
-> Q be db s (rel (Nullable (QExpr be s))) 

Used to define one-to-many (or one-to-one) relationships with a nullable foreign key. Takes the table to fetch, a way to extract the foreign key from that table, and the table to relate to.

data ReusableQ be db res Source #

data With be (db :: (* -> *) -> *) a Source #

Instances
Monad (With be db) Source # 
Instance details

Defined in Database.Beam.Query.CTE

Methods

(>>=) :: With be db a -> (a -> With be db b) -> With be db b #

(>>) :: With be db a -> With be db b -> With be db b #

return :: a -> With be db a #

fail :: String -> With be db a #

Functor (With be db) Source # 
Instance details

Defined in Database.Beam.Query.CTE

Methods

fmap :: (a -> b) -> With be db a -> With be db b #

(<$) :: a -> With be db b -> With be db a #

IsSql99RecursiveCommonTableExpressionSelectSyntax (BeamSqlBackendSelectSyntax be) => MonadFix (With be db) Source # 
Instance details

Defined in Database.Beam.Query.CTE

Methods

mfix :: (a -> With be db a) -> With be db a #

Applicative (With be db) Source # 
Instance details

Defined in Database.Beam.Query.CTE

Methods

pure :: a -> With be db a #

(<*>) :: With be db (a -> b) -> With be db a -> With be db b #

liftA2 :: (a -> b -> c) -> With be db a -> With be db b -> With be db c #

(*>) :: With be db a -> With be db b -> With be db b #

(<*) :: With be db a -> With be db b -> With be db a #

selecting :: forall res be db. (BeamSql99CommonTableExpressionBackend be, HasQBuilder be, Projectible be res, ThreadRewritable QAnyScope res) => Q be db QAnyScope res -> With be db (ReusableQ be db res) Source #

reuse :: forall s be db res. ReusableQ be db res -> Q be db s (WithRewrittenThread QAnyScope s res) Source #

SQL EXTRACT support

newtype ExtractField be tgt a Source #

A field that can be extracted from SQL expressions of type tgt that results in a type a, in backend be.

extract_ :: BeamSqlBackend be => ExtractField be tgt a -> QGenExpr ctxt be s tgt -> QGenExpr cxt be s a Source #

Extracts the given field from the target expression

SQL92 fields

hour_ :: (BeamSqlBackend be, HasSqlTime tgt) => ExtractField be tgt Double Source #

Extracts the hours, minutes, or seconds from any timestamp or time field

minutes_ :: (BeamSqlBackend be, HasSqlTime tgt) => ExtractField be tgt Double Source #

Extracts the hours, minutes, or seconds from any timestamp or time field

seconds_ :: (BeamSqlBackend be, HasSqlTime tgt) => ExtractField be tgt Double Source #

Extracts the hours, minutes, or seconds from any timestamp or time field

class HasSqlTime tgt Source #

Type-class for types that contain a time component

Instances
HasSqlTime UTCTime Source # 
Instance details

Defined in Database.Beam.Query.Extract

HasSqlTime LocalTime Source # 
Instance details

Defined in Database.Beam.Query.Extract

HasSqlTime TimeOfDay Source # 
Instance details

Defined in Database.Beam.Query.Extract

class HasSqlDate tgt Source #

Type-class for types that contain a date component

Instances
HasSqlDate UTCTime Source # 
Instance details

Defined in Database.Beam.Query.Extract

HasSqlDate LocalTime Source # 
Instance details

Defined in Database.Beam.Query.Extract

HasSqlDate Day Source # 
Instance details

Defined in Database.Beam.Query.Extract

Operators

(&&.) :: BeamSqlBackend be => QGenExpr context be s Bool -> QGenExpr context be s Bool -> QGenExpr context be s Bool infixr 3 Source #

SQL AND operator

(||.) :: BeamSqlBackend be => QGenExpr context be s Bool -> QGenExpr context be s Bool -> QGenExpr context be s Bool infixr 2 Source #

SQL OR operator

(&&?.) :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s SqlBool -> QGenExpr context be s SqlBool infixr 3 Source #

SQL AND operator for SqlBool

(||?.) :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s SqlBool -> QGenExpr context be s SqlBool infixr 2 Source #

SQL OR operator

like_ :: (BeamSqlBackendIsString be text, BeamSqlBackend be) => QGenExpr ctxt be s text -> QGenExpr ctxt be s text -> QGenExpr ctxt be s Bool infix 4 Source #

SQL LIKE operator

similarTo_ :: (BeamSqlBackendIsString be text, BeamSql99ExpressionBackend be) => QGenExpr ctxt be s text -> QGenExpr ctxt be s text -> QGenExpr ctxt be s text infix 4 Source #

SQL99 SIMILAR TO operator

not_ :: forall be context s. BeamSqlBackend be => QGenExpr context be s Bool -> QGenExpr context be s Bool Source #

SQL NOT operator

sqlNot_ :: forall be context s. BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s SqlBool Source #

SQL NOT operator, but operating on SqlBool instead

div_ :: (Integral a, BeamSqlBackend be) => QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s a infixl 7 Source #

SQL / operator

mod_ :: (Integral a, BeamSqlBackend be) => QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s a infixl 7 Source #

SQL % operator

concat_ :: BeamSql99ConcatExpressionBackend be => [QGenExpr context be s Text] -> QGenExpr context be s Text Source #

SQL CONCAT function

ANSI SQL Booleans

data SqlBool Source #

Phantom type representing a SQL Tri-state boolean -- true, false, and unknown

This type has no values because it cannot be sent to or retrieved from the database directly. Use isTrue_, isFalse_, isNotTrue_, isNotFalse_, isUnknown_, isNotUnknown_, and unknownAs_ to retrieve the corresponding Bool value.

isTrue_ :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s Bool Source #

SQL IS TRUE operator

isNotTrue_ :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s Bool Source #

SQL IS NOT TRUE operator

isFalse_ :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s Bool Source #

SQL IS FALSE operator

isNotFalse_ :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s Bool Source #

SQL IS NOT FALSE operator

isUnknown_ :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s Bool Source #

SQL IS UNKNOWN operator

isNotUnknown_ :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s Bool Source #

SQL IS NOT UNKNOWN operator

unknownAs_ :: BeamSqlBackend be => Bool -> QGenExpr context be s SqlBool -> QGenExpr context be s Bool Source #

Return the first argument if the expression has the unknown SQL value See sqlBool_ for the inverse

sqlBool_ :: QGenExpr context syntax s Bool -> QGenExpr context syntax s SqlBool Source #

Convert a known not null bool to a SqlBool. See unknownAs_ for the inverse

possiblyNullBool_ :: QGenExpr context be s SqlBool -> QGenExpr context be s (Maybe Bool) Source #

Retrieve a SqlBool value as a potentially NULL Bool. This is useful if you want to get the value of a SQL boolean expression directly, without having to specify what to do on UNKNOWN. Note that both NULL and UNKNOWN will be returned as Nothing.

fromPossiblyNullBool_ :: QGenExpr context be s (Maybe Bool) -> QGenExpr context be s SqlBool Source #

Convert a possibly NULL Bool to a SqlBool.

Unquantified comparison operators

class BeamSqlBackend be => HasSqlEqualityCheck be a where Source #

Class for Haskell types that can be compared for equality in the given backend

Minimal complete definition

Nothing

Instances
HasSqlEqualityCheck be a => HasSqlEqualityCheck be (SqlSerial a) Source # 
Instance details

Defined in Database.Beam.Query.Ord

(HasSqlEqualityCheck be a, CanCheckMaybeEquality a) => HasSqlEqualityCheck be (Maybe a) Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) TimeOfDay Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Day Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) LocalTime Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) UTCTime Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Bool Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Float Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Double Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Word64 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Word32 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Word16 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Word8 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Word Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Int64 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Int32 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Int16 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Int8 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Int Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Integer Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Text Source # 
Instance details

Defined in Database.Beam.Query.Ord

(BeamSqlBackend (MockSqlBackend cmd), HasSqlEqualityCheck (MockSqlBackend cmd) a) => HasSqlEqualityCheck (MockSqlBackend cmd) (Tagged t a) Source # 
Instance details

Defined in Database.Beam.Query.Ord

class HasSqlEqualityCheck be a => HasSqlQuantifiedEqualityCheck be a where Source #

Class for Haskell types that can be compared for quantified equality in the given backend

Minimal complete definition

Nothing

Instances
HasSqlQuantifiedEqualityCheck syntax a => HasSqlQuantifiedEqualityCheck syntax (SqlSerial a) Source # 
Instance details

Defined in Database.Beam.Query.Ord

(HasSqlQuantifiedEqualityCheck syntax a, CanCheckMaybeEquality a) => HasSqlQuantifiedEqualityCheck syntax (Maybe a) Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) TimeOfDay Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Day Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) LocalTime Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) UTCTime Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Bool Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Float Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Double Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Word64 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Word32 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Word16 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Word8 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Word Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Int64 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Int32 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Int16 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Int8 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Int Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Integer Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Text Source # 
Instance details

Defined in Database.Beam.Query.Ord

(BeamSqlBackend (MockSqlBackend cmd), HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) a) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) (Tagged t a) Source # 
Instance details

Defined in Database.Beam.Query.Ord

class SqlEq expr a | a -> expr where Source #

Class for expression types or expression containers for which there is a notion of equality.

Instances are provided to check the equality of expressions of the same type as well as entire Beamable types parameterized over QGenExpr

Methods

(==.) :: a -> a -> expr Bool infix 4 Source #

Given two expressions, returns whether they are equal, using Haskell semantics (NULLs handled properly)

(/=.) :: a -> a -> expr Bool infix 4 Source #

Given two expressions, returns whether they are not equal, using Haskell semantics (NULLs handled properly)

(==?.) :: a -> a -> expr SqlBool Source #

Given two expressions, returns the SQL tri-state boolean when compared for equality

(/=?.) :: a -> a -> expr SqlBool Source #

Given two expressions, returns the SQL tri-state boolean when compared for inequality

Instances
(BeamSqlBackend be, Beamable tbl, FieldsFulfillConstraintNullable (HasSqlEqualityCheck be) tbl) => SqlEq (QGenExpr context be s) (tbl (Nullable (QGenExpr context be s))) Source # 
Instance details

Defined in Database.Beam.Query.Ord

Methods

(==.) :: tbl (Nullable (QGenExpr context be s)) -> tbl (Nullable (QGenExpr context be s)) -> QGenExpr context be s Bool Source #

(/=.) :: tbl (Nullable (QGenExpr context be s)) -> tbl (Nullable (QGenExpr context be s)) -> QGenExpr context be s Bool Source #

(==?.) :: tbl (Nullable (QGenExpr context be s)) -> tbl (Nullable (QGenExpr context be s)) -> QGenExpr context be s SqlBool Source #

(/=?.) :: tbl (Nullable (QGenExpr context be s)) -> tbl (Nullable (QGenExpr context be s)) -> QGenExpr context be s SqlBool Source #

(BeamSqlBackend be, Beamable tbl, FieldsFulfillConstraint (HasSqlEqualityCheck be) tbl) => SqlEq (QGenExpr context be s) (tbl (QGenExpr context be s)) Source #

Compare two arbitrary Beamable types containing QGenExprs for equality.

Instance details

Defined in Database.Beam.Query.Ord

Methods

(==.) :: tbl (QGenExpr context be s) -> tbl (QGenExpr context be s) -> QGenExpr context be s Bool Source #

(/=.) :: tbl (QGenExpr context be s) -> tbl (QGenExpr context be s) -> QGenExpr context be s Bool Source #

(==?.) :: tbl (QGenExpr context be s) -> tbl (QGenExpr context be s) -> QGenExpr context be s SqlBool Source #

(/=?.) :: tbl (QGenExpr context be s) -> tbl (QGenExpr context be s) -> QGenExpr context be s SqlBool Source #

(BeamSqlBackend be, HasSqlEqualityCheck be a) => SqlEq (QGenExpr context be s) (QGenExpr context be s a) Source #

Compare two arbitrary expressions (of the same type) for equality

Instance details

Defined in Database.Beam.Query.Ord

Methods

(==.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool Source #

(/=.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool Source #

(==?.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s SqlBool Source #

(/=?.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s SqlBool Source #

class SqlOrd expr e | e -> expr where Source #

Class for expression types or expression containers for which there is a notion of ordering.

Instances are provided to check the ordering of expressions of the same type. Since there is no universal notion of ordering for an arbitrary number of expressions, no instance is provided for Beamable types.

Methods

(<.) :: e -> e -> expr Bool infix 4 Source #

(>.) :: e -> e -> expr Bool infix 4 Source #

(<=.) :: e -> e -> expr Bool infix 4 Source #

(>=.) :: e -> e -> expr Bool infix 4 Source #

Instances
BeamSqlBackend be => SqlOrd (QGenExpr context be s) (QGenExpr context be s a) Source # 
Instance details

Defined in Database.Beam.Query.Ord

Methods

(<.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool Source #

(>.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool Source #

(<=.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool Source #

(>=.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool Source #

Quantified Comparison Operators

class SqlEq expr a => SqlEqQuantified expr quantified a | a -> expr quantified where Source #

Class for expression types for which there is a notion of quantified equality.

Methods

(==*.) :: a -> quantified -> expr SqlBool infix 4 Source #

Quantified equality and inequality using SQL semantics (tri-state boolean)

(/=*.) :: a -> quantified -> expr SqlBool infix 4 Source #

Quantified equality and inequality using SQL semantics (tri-state boolean)

Instances
(BeamSqlBackend be, HasSqlQuantifiedEqualityCheck be a) => SqlEqQuantified (QGenExpr context be s) (QQuantified be s a) (QGenExpr context be s a) Source #

Two arbitrary expressions can be quantifiably compared for equality.

Instance details

Defined in Database.Beam.Query.Ord

Methods

(==*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s SqlBool Source #

(/=*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s SqlBool Source #

class SqlOrd expr e => SqlOrdQuantified expr quantified e | e -> expr quantified where Source #

Class for things which can be quantifiably compared.

Methods

(<*.) :: e -> quantified -> expr Bool infix 4 Source #

(>*.) :: e -> quantified -> expr Bool infix 4 Source #

(<=*.) :: e -> quantified -> expr Bool infix 4 Source #

(>=*.) :: e -> quantified -> expr Bool infix 4 Source #

Instances
BeamSqlBackend be => SqlOrdQuantified (QGenExpr context be s) (QQuantified be s a) (QGenExpr context be s a) Source # 
Instance details

Defined in Database.Beam.Query.Ord

Methods

(<*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool Source #

(>*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool Source #

(<=*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool Source #

(>=*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool Source #

data QQuantified be s r Source #

A data structure representing the set to quantify a comparison operator over.

Instances
BeamSqlBackend be => SqlOrdQuantified (QGenExpr context be s) (QQuantified be s a) (QGenExpr context be s a) Source # 
Instance details

Defined in Database.Beam.Query.Ord

Methods

(<*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool Source #

(>*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool Source #

(<=*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool Source #

(>=*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool Source #

(BeamSqlBackend be, HasSqlQuantifiedEqualityCheck be a) => SqlEqQuantified (QGenExpr context be s) (QQuantified be s a) (QGenExpr context be s a) Source #

Two arbitrary expressions can be quantifiably compared for equality.

Instance details

Defined in Database.Beam.Query.Ord

Methods

(==*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s SqlBool Source #

(/=*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s SqlBool Source #

anyOf_ :: forall s a be db. (BeamSqlBackend be, HasQBuilder be) => Q be db (QNested s) (QExpr be (QNested s) a) -> QQuantified be s a Source #

A QQuantified representing a SQL ANY(..) for use with a quantified comparison operator

Accepts a subquery. Use anyIn_ for an explicit list

allOf_ :: forall s a be db. (BeamSqlBackend be, HasQBuilder be) => Q be db (QNested s) (QExpr be (QNested s) a) -> QQuantified be s a Source #

A QQuantified representing a SQL ALL(..) for use with a quantified comparison operator

Accepts a subquery. Use allIn_ for an explicit list

anyIn_ :: forall s a be. BeamSqlBackend be => [QExpr be s a] -> QQuantified be s a Source #

A QQuantified representing a SQL ANY(..) for use with a quantified comparison operator

Accepts an explicit list of typed expressions. Use anyOf_ for a subquery

allIn_ :: forall s a be. BeamSqlBackend be => [QExpr be s a] -> QQuantified be s a Source #

A QQuantified representing a SQL ALL(..) for use with a quantified comparison operator

Accepts an explicit list of typed expressions. Use allOf_ for a subquery

between_ :: BeamSqlBackend be => QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool infix 4 Source #

SQL BETWEEN clause

in_ :: BeamSqlBackend be => QGenExpr context be s a -> [QGenExpr context be s a] -> QGenExpr context be s Bool infix 4 Source #

SQL IN predicate

Aggregates

See the corresponding manual section for more detail

aggregate_ Source #

Arguments

:: (BeamSqlBackend be, Aggregable be a, Projectible be r, Projectible be a, ContextRewritable a, ThreadRewritable (QNested s) (WithRewrittenContext a QValueContext)) 
=> (r -> a)

Aggregate projection

-> Q be db (QNested s) r

Query to aggregate over

-> Q be db s (WithRewrittenThread (QNested s) s (WithRewrittenContext a QValueContext)) 

Compute an aggregate over a query.

The supplied aggregate projection should return an aggregate expression (an expression containing an aggregate function such as count_, sum_, countAll_, etc), a grouping key (specified with the group_ function), or a combination of tuples of the above.

Appropriate instances are provided up to 8-tuples.

Semantically, all grouping expressions in the projection will be added to a SQL GROUP BY clause and all aggregate expressions will be computed.

The return value will be the type of the aggregate projection, but transformed to be in the normal value context (i.e., everything will become QGenExprs).

For usage examples, see the manual.

filterWhere_ :: BeamSqlT611Backend be => QAgg be s a -> QExpr be s Bool -> QAgg be s a Source #

Support for FILTER (WHERE ...) syntax for aggregates. Part of SQL2003 Elementary OLAP operations feature (T611).

See filterWhere_' for a version that accepts SqlBool.

filterWhere_' :: BeamSqlT611Backend be => QAgg be s a -> QExpr be s SqlBool -> QAgg be s a Source #

Like filterWhere_ but accepting SqlBool.

class QGroupable expr grouped | expr -> grouped, grouped -> expr where Source #

Type class for grouping keys. expr is the type of the grouping key after projection. grouped is the type of the grouping key in the aggregate expression (usually something that contains QGenExprs in the QGroupingContext).

Methods

group_ :: expr -> grouped Source #

Instances
Beamable tbl => QGroupable (tbl (Nullable (QExpr be s))) (tbl (Nullable (QGroupExpr be s))) Source #

group_ for any Beamable type. Adds every field in the type to the grouping key. This is the equivalent of including the grouping expression of each field in the type as part of the aggregate projection

Instance details

Defined in Database.Beam.Query.Aggregate

Methods

group_ :: tbl (Nullable (QExpr be s)) -> tbl (Nullable (QGroupExpr be s)) Source #

Beamable tbl => QGroupable (tbl (QExpr be s)) (tbl (QGroupExpr be s)) Source #

group_ for any Beamable type. Adds every field in the type to the grouping key. This is the equivalent of including the grouping expression of each field in the type as part of the aggregate projection

Instance details

Defined in Database.Beam.Query.Aggregate

Methods

group_ :: tbl (QExpr be s) -> tbl (QGroupExpr be s) Source #

QGroupable (QExpr be s a) (QGroupExpr be s a) Source #

group_ for simple value expressions.

Instance details

Defined in Database.Beam.Query.Aggregate

Methods

group_ :: QExpr be s a -> QGroupExpr be s a Source #

General-purpose aggregate functions

sum_ :: (BeamSqlBackend be, Num a) => QExpr be s a -> QAgg be s (Maybe a) Source #

SQL SUM(ALL ..) function (but without the explicit ALL)

avg_ :: (BeamSqlBackend be, Num a) => QExpr be s a -> QAgg be s (Maybe a) Source #

SQL AVG(ALL ..) function (but without the explicit ALL)

min_ :: BeamSqlBackend be => QExpr be s a -> QAgg be s (Maybe a) Source #

SQL MIN(ALL ..) function (but without the explicit ALL)

max_ :: BeamSqlBackend be => QExpr be s a -> QAgg be s (Maybe a) Source #

SQL MAX(ALL ..) function (but without the explicit ALL)

count_ :: (BeamSqlBackend be, Integral b) => QExpr be s a -> QAgg be s b Source #

SQL COUNT(ALL ..) function (but without the explicit ALL)

countAll_ :: BeamSqlBackend be => QAgg be s Int Source #

SQL COUNT(*) function

rank_ :: BeamSqlT611Backend be => QAgg be s Int Source #

SQL2003 RANK function (Requires T611 Elementary OLAP operations support)

cumeDist_ :: BeamSqlT612Backend be => QAgg be s Double Source #

SQL2003 CUME_DIST function (Requires T612 Advanced OLAP operations support)

percentRank_ :: BeamSqlT612Backend be => QAgg be s Double Source #

SQL2003 PERCENT_RANK function (Requires T612 Advanced OLAP operations support)

denseRank_ :: BeamSqlT612Backend be => QAgg be s Int Source #

SQL2003 DENSE_RANK function (Requires T612 Advanced OLAP operations support)

rowNumber_ :: BeamSql2003ExpressionBackend be => QAgg be s Int Source #

SQL2003 ROW_NUMBER function

every_ :: BeamSql99AggregationBackend be => QExpr be s SqlBool -> QAgg be s SqlBool Source #

SQL99 EVERY(ALL ..) function (but without the explicit ALL)

any_ :: BeamSql99AggregationBackend be => QExpr be s SqlBool -> QAgg be s SqlBool Source #

SQL99 ANY(ALL ..) function (but without the explicit ALL)

some_ :: BeamSql99AggregationBackend be => QExpr be s SqlBool -> QAgg be s SqlBool Source #

SQL99 SOME(ALL ..) function (but without the explicit ALL)

Quantified aggregate functions

These functions correspond one-to-one with the <#gp-agg-funcs general-purpose aggregate functions>. However, they each take a mandatory "set quantifier", which is any of the set quantifier values.

everyOver_ :: BeamSql99AggregationBackend be => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s SqlBool -> QAgg be s SqlBool Source #

SQL EVERY, SOME, and ANY aggregates. Operates over SqlBool only, as the result can be NULL, even if all inputs are known (no input rows).

anyOver_ :: BeamSql99AggregationBackend be => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s SqlBool -> QAgg be s SqlBool Source #

SQL EVERY, SOME, and ANY aggregates. Operates over SqlBool only, as the result can be NULL, even if all inputs are known (no input rows).

someOver_ :: BeamSql99AggregationBackend be => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s SqlBool -> QAgg be s SqlBool Source #

SQL EVERY, SOME, and ANY aggregates. Operates over SqlBool only, as the result can be NULL, even if all inputs are known (no input rows).

Set quantifiers

distinctInGroup_ :: IsSql92AggregationSetQuantifierSyntax s => Maybe s Source #

Compute an aggregate only over distinct values in a group. Corresponds to the AGG(DISTINCT ..) syntax.

allInGroup_ :: IsSql92AggregationSetQuantifierSyntax s => Maybe s Source #

Compute an aggregate over all values in a group. Corresponds semantically to the AGG(ALL ..) syntax, but doesn't produce an explicit ALL. To produce ALL expicitly, see allInGroupExplicitly_.

allInGroupExplicitly_ :: IsSql92AggregationSetQuantifierSyntax s => Maybe s Source #

Compute an aggregate over all values in a group. Corresponds to the AGG(ALL ..) syntax. Note that ALL is the default for most aggregations, so you don't normally explicitly specify ALL. However, if you need to, you can use this function. To be explicit about quantification in the beam query DSL, but not produce an explicit ALL, use allInGroup_. allInGroup_ has the same semantic meaning, but does not produce an explicit ALL.

SQL Command construction and execution

SELECT

newtype SqlSelect be a Source #

Represents a select statement in the given backend, returning rows of type a.

select :: forall be db res. (BeamSqlBackend be, HasQBuilder be, Projectible be res) => Q be db QBaseScope res -> SqlSelect be (QExprToIdentity res) Source #

Build a SqlSelect for the given Q.

selectWith :: forall be db res. (BeamSqlBackend be, BeamSql99CommonTableExpressionBackend be, HasQBuilder be, Projectible be res) => With be db (Q be db QBaseScope res) -> SqlSelect be (QExprToIdentity res) Source #

Create a SqlSelect for a query which may have common table expressions. See the documentation of With for more details.

lookup_ :: (Database be db, Table table, BeamSqlBackend be, HasQBuilder be, SqlValableTable be (PrimaryKey table), HasTableEquality be (PrimaryKey table)) => DatabaseEntity be db (TableEntity table) -> PrimaryKey table Identity -> SqlSelect be (table Identity) Source #

Convenience function to generate a SqlSelect that looks up a table row given a primary key.

runSelectReturningList :: (MonadBeam be m, BeamSqlBackend be, FromBackendRow be a) => SqlSelect be a -> m [a] Source #

Run a SqlSelect in a MonadBeam and get the results as a list

runSelectReturningOne :: (MonadBeam be m, BeamSqlBackend be, FromBackendRow be a) => SqlSelect be a -> m (Maybe a) Source #

Run a SqlSelect in a MonadBeam and get the unique result, if there is one. Both no results as well as more than one result cause this to return Nothing.

dumpSqlSelect :: Projectible (MockSqlBackend SqlSyntaxBuilder) res => Q (MockSqlBackend SqlSyntaxBuilder) db QBaseScope res -> IO () Source #

Use a special debug syntax to print out an ANSI Standard SELECT statement that may be generated for a given Q.

INSERT

data SqlInsert be (table :: (* -> *) -> *) Source #

Represents a SQL INSERT command that has not yet been run

insert Source #

Arguments

:: (BeamSqlBackend be, ProjectibleWithPredicate AnyType () Text (table (QField s))) 
=> DatabaseEntity be db (TableEntity table)

Table to insert into

-> SqlInsertValues be (table (QExpr be s))

Values to insert. See insertValues, insertExpressions, and insertFrom for possibilities.

-> SqlInsert be table 

Generate a SqlInsert given a table and a source of values.

insertOnly Source #

Arguments

:: (BeamSqlBackend be, ProjectibleWithPredicate AnyType () Text (QExprToField r)) 
=> DatabaseEntity be db (TableEntity table)

Table to insert into

-> (table (QField s) -> QExprToField r) 
-> SqlInsertValues be r

Values to insert. See insertValues, insertExpressions, insertData, and insertFrom for possibilities.

-> SqlInsert be table 

Generate a SqlInsert over only certain fields of a table

runInsert :: (BeamSqlBackend be, MonadBeam be m) => SqlInsert be table -> m () Source #

Run a SqlInsert in a MonadBeam

data SqlInsertValues be proj Source #

Represents a source of values that can be inserted into a table shaped like tbl.

insertExpressions :: forall be table s. (BeamSqlBackend be, Beamable table) => (forall s'. [table (QExpr be s')]) -> SqlInsertValues be (table (QExpr be s)) Source #

Build a SqlInsertValues from series of expressions in tables

insertValues :: forall be table s. (BeamSqlBackend be, Beamable table, FieldsFulfillConstraint (BeamSqlBackendCanSerialize be) table) => [table Identity] -> SqlInsertValues be (table (QExpr be s)) Source #

Build a SqlInsertValues from concrete table values

insertFrom :: (BeamSqlBackend be, HasQBuilder be, Projectible be r) => Q be db QBaseScope r -> SqlInsertValues be r Source #

Build a SqlInsertValues from a SqlSelect that returns the same table

insertData :: forall be r. (Projectible be r, BeamSqlBackend be) => [r] -> SqlInsertValues be r Source #

Build a SqlInsertValues from arbitrarily shaped data containing expressions

UPDATE

data SqlUpdate be (table :: (* -> *) -> *) Source #

Represents a SQL UPDATE statement for the given table.

update Source #

Arguments

:: (BeamSqlBackend be, Beamable table) 
=> DatabaseEntity be db (TableEntity table)

The table to insert into

-> (forall s. table (QField s) -> QAssignment be s)

A sequence of assignments to make.

-> (forall s. table (QExpr be s) -> QExpr be s Bool)

Build a WHERE clause given a table containing expressions

-> SqlUpdate be table 

Build a SqlUpdate given a table, a list of assignments, and a way to build a WHERE clause.

See the '(<-.)' operator for ways to build assignments. The argument to the second argument is a the table parameterized over QField, which represents the left hand side of assignments. Sometimes, you'd like to also get the current value of a particular column. You can use the current_ function to convert a QField to a QGenExpr.

save Source #

Arguments

:: (Table table, BeamSqlBackend be, SqlValableTable be (PrimaryKey table), SqlValableTable be table, HasTableEquality be (PrimaryKey table)) 
=> DatabaseEntity be db (TableEntity table)

Table to update

-> table Identity

Value to set to

-> SqlUpdate be table 

Generate a SqlUpdate that will update the given table row with the given value.

The SQL UPDATE that is generated will set every non-primary key field for the row where each primary key field is exactly what is given.

Note: This is a pure SQL UPDATE command. This does not upsert or merge values.

updateTable Source #

Arguments

:: (BeamSqlBackend be, Beamable table) 
=> DatabaseEntity be db (TableEntity table)

The table to update

-> table (QFieldAssignment be table)

Updates to be made (use set to construct an empty field)

-> (forall s. table (QExpr be s) -> QExpr be s Bool) 
-> SqlUpdate be table 

A specialization of update that is more convenient for normal tables.

set :: forall table be table'. Beamable table => table (QFieldAssignment be table') Source #

setFieldsTo :: forall table be table'. Table table => (forall s. table (QExpr be s)) -> table (QFieldAssignment be table') Source #

toNewValue :: (forall s. QExpr be s a) -> QFieldAssignment be table a Source #

Use with set to set a field to an explicit new value that does not depend on any other value

toOldValue :: QFieldAssignment be table a Source #

Use with set to not modify the field

toUpdatedValue :: (forall s. table (QExpr be s) -> QExpr be s a) -> QFieldAssignment be table a Source #

Use with set to set a field to a new value that is calculated based on one or more fields from the existing row

toUpdatedValueMaybe :: (forall s. table (QExpr be s) -> Maybe (QExpr be s a)) -> QFieldAssignment be table a Source #

Use with set to optionally set a fiield to a new value, calculated based on one or more fields from the existing row

updateRow Source #

Arguments

:: (BeamSqlBackend be, Table table, HasTableEquality be (PrimaryKey table), SqlValableTable be (PrimaryKey table)) 
=> DatabaseEntity be db (TableEntity table)

The table to insert into

-> table Identity

The row to update

-> (forall s. table (QField s) -> QAssignment be s)

A sequence of assignments to make.

-> SqlUpdate be table 

A specialization of update that matches the given (already existing) row

updateTableRow Source #

Arguments

:: (BeamSqlBackend be, Table table, HasTableEquality be (PrimaryKey table), SqlValableTable be (PrimaryKey table)) 
=> DatabaseEntity be db (TableEntity table)

The table to update

-> table Identity

The row to update

-> table (QFieldAssignment be table)

Updates to be made (use set to construct an empty field)

-> SqlUpdate be table 

Convenience form of updateTable that generates a WHERE clause that matches only the already existing entity

runUpdate :: (BeamSqlBackend be, MonadBeam be m) => SqlUpdate be tbl -> m () Source #

Run a SqlUpdate in a MonadBeam.

DELETE

data SqlDelete be (table :: (* -> *) -> *) Source #

Represents a SQL DELETE statement for the given table

delete Source #

Arguments

:: BeamSqlBackend be 
=> DatabaseEntity be db (TableEntity table)

Table to delete from

-> (forall s. (forall s'. table (QExpr be s')) -> QExpr be s Bool)

Build a WHERE clause given a table containing expressions

-> SqlDelete be table 

Build a SqlDelete from a table and a way to build a WHERE clause

runDelete :: (BeamSqlBackend be, MonadBeam be m) => SqlDelete be table -> m () Source #

Run a SqlDelete in a MonadBeam