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

Safe HaskellNone
LanguageHaskell2010

Database.Beam.Query

Contents

Synopsis

Query type

data Aggregation syntax s a Source #

data QWindow syntax s Source #

Instances
ProjectibleWithPredicate WindowFrameContext syntax (QWindow syntax s) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

project' :: Monad m => Proxy WindowFrameContext -> (forall context. WindowFrameContext context => Proxy context -> WithExprContext syntax -> m (WithExprContext syntax)) -> QWindow syntax s -> m (QWindow syntax s) Source #

type QExpr = QGenExpr QValueContext Source #

QGenExprs represent expressions not containing aggregates.

newtype QGenExpr context syntax 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).

Constructors

QExpr (TablePrefix -> syntax) 
Instances
(Beamable t, contextPredicate context) => ProjectibleWithPredicate contextPredicate syntax (t (Nullable (QGenExpr context syntax s))) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

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

(Beamable t, contextPredicate context) => ProjectibleWithPredicate contextPredicate syntax (t (QGenExpr context syntax s)) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

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

contextPredicate context => ProjectibleWithPredicate contextPredicate syntax (QGenExpr context syntax s a) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

project' :: Monad m => Proxy contextPredicate -> (forall context0. contextPredicate context0 => Proxy context0 -> WithExprContext syntax -> m (WithExprContext syntax)) -> QGenExpr context syntax s a -> m (QGenExpr context syntax 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 #

(IsSql92ExpressionSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) Bool, Beamable t) => SqlDeconstructMaybe syntax (t (Nullable (QGenExpr ctxt syntax s))) (t (QGenExpr ctxt syntax s)) s Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

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

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

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

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

Defined in Database.Beam.Query.Combinators

Methods

makeSQLOrdering :: QOrd syntax s a -> [WithExprContext syntax]

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 #

IsSql92ExpressionSyntax syntax => SqlDeconstructMaybe syntax (QGenExpr ctxt syntax s (Maybe x)) (QGenExpr ctxt syntax s x) s Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

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

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

maybe_ :: QGenExpr ctxt0 syntax s y -> (QGenExpr ctxt syntax s x -> QGenExpr ctxt0 syntax s y) -> QGenExpr ctxt syntax s (Maybe x) -> QGenExpr ctxt0 syntax 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, IsSql92ExpressionSyntax syntax, FieldsFulfillConstraintNullable (HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax)) table) => SqlValable (table (Nullable (QGenExpr ctxt syntax s))) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

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

(Beamable table, IsSql92ExpressionSyntax syntax, FieldsFulfillConstraint (HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax)) table) => SqlValable (table (QGenExpr ctxt syntax s)) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

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

(Table t, IsSql92ExpressionSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) SqlNull) => SqlJustable (t (QExpr syntax s)) (t (Nullable (QExpr syntax s))) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

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

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

Beamable tbl => QGroupable (tbl (QExpr expr s)) (tbl (QGroupExpr expr 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 expr s) -> tbl (QGroupExpr expr s) Source #

(Table t, IsSql92ExpressionSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) SqlNull) => SqlJustable (PrimaryKey t (QExpr syntax s)) (PrimaryKey t (Nullable (QExpr syntax s))) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

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

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

(IsSql92ExpressionSyntax syntax, FieldsFulfillConstraintNullable (HasSqlEqualityCheck syntax) tbl, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) Bool, Beamable tbl) => SqlEq (QGenExpr context syntax s) (tbl (Nullable (QGenExpr context syntax s))) Source # 
Instance details

Defined in Database.Beam.Query.Ord

Methods

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

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

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

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

(IsSql92ExpressionSyntax syntax, FieldsFulfillConstraint (HasSqlEqualityCheck syntax) tbl, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) Bool, Beamable tbl) => SqlEq (QGenExpr context syntax s) (tbl (QGenExpr context syntax s)) Source #

Compare two arbitrary Beamable types containing QGenExprs for equality.

Instance details

Defined in Database.Beam.Query.Ord

Methods

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

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

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

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

(IsSql92ExpressionSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) SqlNull) => SqlJustable (QExpr syntax s a) (QExpr syntax s (Maybe a)) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

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

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

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

group_ for simple value expressions.

Instance details

Defined in Database.Beam.Query.Aggregate

Methods

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

IsSql92ExpressionSyntax syntax => SqlOrdQuantified (QGenExpr context syntax s) (QQuantified syntax s a) (QGenExpr context syntax s a) Source # 
Instance details

Defined in Database.Beam.Query.Ord

Methods

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

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

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

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

(IsSql92ExpressionSyntax syntax, HasSqlQuantifiedEqualityCheck syntax a) => SqlEqQuantified (QGenExpr context syntax s) (QQuantified syntax s a) (QGenExpr context syntax s a) Source #

Two arbitrary expressions can be quantifiably compared for equality.

Instance details

Defined in Database.Beam.Query.Ord

Methods

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

(/=*.) :: QGenExpr context syntax s a -> QQuantified syntax s a -> QGenExpr context syntax 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 #

IsSql92ExpressionSyntax syntax => SqlOrd (QGenExpr context syntax s) (QGenExpr context syntax s a) Source # 
Instance details

Defined in Database.Beam.Query.Ord

Methods

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

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

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

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

(IsSql92ExpressionSyntax syntax, HasSqlEqualityCheck syntax a) => SqlEq (QGenExpr context syntax s) (QGenExpr context syntax s a) Source #

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

Instance details

Defined in Database.Beam.Query.Ord

Methods

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

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

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

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

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

Defined in Database.Beam.Query.Internal

Methods

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

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

(Fractional a, IsSql92ExpressionSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) a) => Fractional (QGenExpr context syntax s a) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

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

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

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

(Num a, IsSql92ExpressionSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) a) => Num (QGenExpr context syntax s a) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

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

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

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

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

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

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

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

(IsSql92ExpressionSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) [Char]) => IsString (QGenExpr context syntax s Text) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

fromString :: String -> QGenExpr context syntax 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 #

(HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) a, IsSql92ExpressionSyntax syntax) => SqlValable (QGenExpr ctxt syntax s a) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

val_ :: HaskellLiteralForQExpr (QGenExpr ctxt syntax s a) -> QGenExpr ctxt syntax 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 syntax s)) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

type HaskellLiteralForQExpr (table (QGenExpr context syntax 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 syntax s a) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

type HaskellLiteralForQExpr (QGenExpr context syntax 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 syntax (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 syntax db s) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

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

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

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

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

Functor (Q syntax db s) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

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

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

Applicative (Q syntax db s) Source # 
Instance details

Defined in Database.Beam.Query.Internal

Methods

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

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

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

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

(<*) :: Q syntax db s a -> Q syntax db s b -> Q syntax 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 (QExpr expr s)) (tbl (QGroupExpr expr 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 expr s) -> tbl (QGroupExpr expr s) Source #

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

group_ for simple value expressions.

Instance details

Defined in Database.Beam.Query.Aggregate

Methods

group_ :: QExpr expr s a -> QGroupExpr expr 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, IsSql92ExpressionSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) SqlNull) => SqlJustable (t (QExpr syntax s)) (t (Nullable (QExpr syntax s))) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

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

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

Beamable tbl => QGroupable (tbl (QExpr expr s)) (tbl (QGroupExpr expr 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 expr s) -> tbl (QGroupExpr expr s) Source #

(Table t, IsSql92ExpressionSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) SqlNull) => SqlJustable (PrimaryKey t (QExpr syntax s)) (PrimaryKey t (Nullable (QExpr syntax s))) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

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

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

(IsSql92ExpressionSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) SqlNull) => SqlJustable (QExpr syntax s a) (QExpr syntax s (Maybe a)) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

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

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

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

group_ for simple value expressions.

Instance details

Defined in Database.Beam.Query.Aggregate

Methods

group_ :: QExpr expr s a -> QGroupExpr expr 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 syntax s tbl = tbl (QGenExpr ctxt syntax s) Source #

A version of the table where each field is a QGenExpr

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

Various SQL functions and constructs

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

SQL COALESCE support

fromMaybe_ :: IsSql92ExpressionSyntax expr => QGenExpr ctxt expr s a -> QGenExpr ctxt expr s (Maybe a) -> QGenExpr ctxt expr s a Source #

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

position_ :: (IsSqlExpressionSyntaxStringType syntax text, IsSql92ExpressionSyntax syntax, Integral b) => QExpr syntax s text -> QExpr syntax s text -> QExpr syntax s b Source #

SQL POSITION(.. IN ..) function

charLength_ :: (IsSqlExpressionSyntaxStringType syntax text, IsSql92ExpressionSyntax syntax) => QGenExpr context syntax s text -> QGenExpr context syntax s Int Source #

SQL CHAR_LENGTH function

octetLength_ :: (IsSqlExpressionSyntaxStringType syntax text, IsSql92ExpressionSyntax syntax) => QGenExpr context syntax s text -> QGenExpr context syntax s Int Source #

SQL OCTET_LENGTH function

bitLength_ :: IsSql92ExpressionSyntax syntax => QGenExpr context syntax s SqlBitString -> QGenExpr context syntax s Int Source #

SQL BIT_LENGTH function

currentTimestamp_ :: IsSql92ExpressionSyntax syntax => QGenExpr ctxt syntax s LocalTime Source #

SQL CURRENT_TIMESTAMP function

lower_ :: (IsSqlExpressionSyntaxStringType syntax text, IsSql92ExpressionSyntax syntax) => QGenExpr context syntax s text -> QGenExpr context syntax s text Source #

SQL LOWER function

upper_ :: (IsSqlExpressionSyntaxStringType syntax text, IsSql92ExpressionSyntax syntax) => QGenExpr context syntax s text -> QGenExpr context syntax s text Source #

SQL UPPER function

trim_ :: (IsSqlExpressionSyntaxStringType syntax text, IsSql92ExpressionSyntax syntax) => QGenExpr context syntax s text -> QGenExpr context syntax s text Source #

SQL TRIM function

IF-THEN-ELSE support

if_ :: IsSql92ExpressionSyntax expr => [QIfCond context expr s a] -> QIfElse context expr s a -> QGenExpr context expr s a Source #

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

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

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

SQL UPDATE assignments

(<-.) :: forall fieldName. (SqlUpdatable expr s lhs rhs, IsSql92FieldNameSyntax fieldName) => lhs -> rhs -> QAssignment fieldName expr s infix 4 Source #

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

current_ :: IsSql92ExpressionSyntax expr => QField s ty -> QExpr expr 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 syntax s)) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

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

Defined in Database.Beam.Query.Combinators

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

Defined in Database.Beam.Query.Combinators

type HaskellLiteralForQExpr (QGenExpr context syntax s a) = a

class SqlValable a where Source #

Instances
(Beamable table, IsSql92ExpressionSyntax syntax, FieldsFulfillConstraintNullable (HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax)) table) => SqlValable (table (Nullable (QGenExpr ctxt syntax s))) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

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

(Beamable table, IsSql92ExpressionSyntax syntax, FieldsFulfillConstraint (HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax)) table) => SqlValable (table (QGenExpr ctxt syntax s)) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

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

(HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) a, IsSql92ExpressionSyntax syntax) => SqlValable (QGenExpr ctxt syntax s a) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

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

General query combinators

join_ :: (Database be db, Table table, IsSql92SelectSyntax select, IsSql92FromSyntax (Sql92SelectTableFromSyntax (Sql92SelectSelectTableSyntax select)), Sql92FromExpressionSyntax (Sql92SelectTableFromSyntax (Sql92SelectSelectTableSyntax select)) ~ Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select), IsSql92TableSourceSyntax (Sql92FromTableSourceSyntax (Sql92SelectTableFromSyntax (Sql92SelectSelectTableSyntax select)))) => DatabaseEntity be db (TableEntity table) -> (table (QExpr (Sql92SelectExpressionSyntax select) s) -> QExpr (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) s Bool) -> Q select db s (table (QExpr (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) 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_'.

guard_ :: forall select db s. IsSql92SelectSyntax select => QExpr (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) s Bool -> Q select 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 select db s. IsSql92SelectSyntax select => QExpr (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) s SqlBool -> Q select 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 select db s. IsSql92SelectSyntax select => (r -> QExpr (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) s Bool) -> Q select db s r -> Q select db s r Source #

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

filter_' :: forall r select db s. IsSql92SelectSyntax select => (r -> QExpr (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) s SqlBool) -> Q select db s r -> Q select db s r Source #

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

related_ :: forall be db rel select s. (IsSql92SelectSyntax select, HasTableEquality (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) (PrimaryKey rel), HasSqlValueSyntax (Sql92ExpressionValueSyntax (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select))) Bool, Database be db, Table rel) => DatabaseEntity be db (TableEntity rel) -> PrimaryKey rel (QExpr (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) s) -> Q select db s (rel (QExpr (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) s)) Source #

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

relatedBy_ :: forall be db rel select s. (Database be db, Table rel, HasSqlValueSyntax (Sql92ExpressionValueSyntax (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select))) Bool, IsSql92SelectSyntax select) => DatabaseEntity be db (TableEntity rel) -> (rel (QExpr (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) s) -> QExpr (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) s Bool) -> Q select db s (rel (QExpr (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) 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 select s. (Database be db, Table rel, HasSqlValueSyntax (Sql92ExpressionValueSyntax (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select))) Bool, IsSql92SelectSyntax select) => DatabaseEntity be db (TableEntity rel) -> (rel (QExpr (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) s) -> QExpr (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) s SqlBool) -> Q select db s (rel (QExpr (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) 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 select db. (Projectible (Sql92SelectExpressionSyntax select) r, IsSql92SelectSyntax select, ThreadRewritable (QNested s) r, Retaggable (QExpr (Sql92SelectExpressionSyntax select) s) (WithRewrittenThread (QNested s) s r)) => Q select db (QNested s) r -> (WithRewrittenThread (QNested s) s r -> QExpr (Sql92SelectExpressionSyntax select) s Bool) -> Q select 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 select db. (Projectible (Sql92SelectExpressionSyntax select) r, IsSql92SelectSyntax select, ThreadRewritable (QNested s) r, Retaggable (QExpr (Sql92SelectExpressionSyntax select) s) (WithRewrittenThread (QNested s) s r)) => Q select db (QNested s) r -> (WithRewrittenThread (QNested s) s r -> QExpr (Sql92SelectExpressionSyntax select) s SqlBool) -> Q select db s (Retag Nullable (WithRewrittenThread (QNested s) s r)) Source #

Like leftJoin_, but accepts an ON clause returning SqlBool.

perhaps_ :: forall s r select db. (Projectible (Sql92SelectExpressionSyntax select) r, IsSql92SelectSyntax select, ThreadRewritable (QNested s) r, Retaggable (QExpr (Sql92SelectExpressionSyntax select) s) (WithRewrittenThread (QNested s) s r)) => Q select db (QNested s) r -> Q select 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 select db. (Projectible (Sql92SelectExpressionSyntax select) a, Projectible (Sql92SelectExpressionSyntax select) b, ThreadRewritable (QNested s) a, ThreadRewritable (QNested s) b, Retaggable (QExpr (Sql92SelectExpressionSyntax select) s) (WithRewrittenThread (QNested s) s a), Retaggable (QExpr (Sql92SelectExpressionSyntax select) s) (WithRewrittenThread (QNested s) s b), IsSql92FromOuterJoinSyntax (Sql92SelectFromSyntax select)) => Q select db (QNested s) a -> Q select db (QNested s) b -> ((WithRewrittenThread (QNested s) s a, WithRewrittenThread (QNested s) s b) -> QExpr (Sql92SelectExpressionSyntax select) s Bool) -> Q select 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 select db. (Projectible (Sql92SelectExpressionSyntax select) a, Projectible (Sql92SelectExpressionSyntax select) b, ThreadRewritable (QNested s) a, ThreadRewritable (QNested s) b, Retaggable (QExpr (Sql92SelectExpressionSyntax select) s) (WithRewrittenThread (QNested s) s a), Retaggable (QExpr (Sql92SelectExpressionSyntax select) s) (WithRewrittenThread (QNested s) s b), IsSql92FromOuterJoinSyntax (Sql92SelectFromSyntax select)) => Q select db (QNested s) a -> Q select db (QNested s) b -> ((WithRewrittenThread (QNested s) s a, WithRewrittenThread (QNested s) s b) -> QExpr (Sql92SelectExpressionSyntax select) s SqlBool) -> Q select 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 select db. (ThreadRewritable (QNested s) r, ProjectibleInSelectSyntax select r) => Q select db (QNested s) r -> Q select db s (WithRewrittenThread (QNested s) s r) Source #

references_ :: (IsSql92ExpressionSyntax expr, HasTableEquality expr (PrimaryKey t), HasSqlValueSyntax (Sql92ExpressionValueSyntax expr) Bool, Table t) => PrimaryKey t (QGenExpr ctxt expr s) -> t (QGenExpr ctxt expr s) -> QGenExpr ctxt expr s Bool Source #

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

nub_ :: (IsSql92SelectSyntax select, Projectible (Sql92SelectExpressionSyntax select) r) => Q select db s r -> Q select 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, IsSql92ExpressionSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) SqlNull) => SqlJustable (t (QExpr syntax s)) (t (Nullable (QExpr syntax s))) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

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

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

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

Defined in Database.Beam.Query.Combinators

(Table t, IsSql92ExpressionSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) SqlNull) => SqlJustable (PrimaryKey t (QExpr syntax s)) (PrimaryKey t (Nullable (QExpr syntax s))) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

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

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

(IsSql92ExpressionSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) SqlNull) => SqlJustable (QExpr syntax s a) (QExpr syntax s (Maybe a)) Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

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

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

class IsSql92ExpressionSyntax syntax => SqlDeconstructMaybe syntax a nonNullA s | a s -> syntax, 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 syntax s Bool Source #

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

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

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

maybe_ :: QGenExpr ctxt syntax s y -> (nonNullA -> QGenExpr ctxt syntax s y) -> a -> QGenExpr ctxt syntax 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
(IsSql92ExpressionSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) Bool, Beamable t) => SqlDeconstructMaybe syntax (t (Nullable (QGenExpr ctxt syntax s))) (t (QGenExpr ctxt syntax s)) s Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

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

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

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

IsSql92ExpressionSyntax syntax => SqlDeconstructMaybe syntax (QGenExpr ctxt syntax s (Maybe x)) (QGenExpr ctxt syntax s x) s Source # 
Instance details

Defined in Database.Beam.Query.Combinators

Methods

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

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

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

class SqlOrderable syntax a | a -> syntax Source #

Minimal complete definition

makeSQLOrdering

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

Defined in Database.Beam.Query.Combinators

Methods

makeSQLOrdering :: [a] -> [WithExprContext syntax]

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

Defined in Database.Beam.Query.Combinators

Methods

makeSQLOrdering :: (a, b) -> [WithExprContext syntax]

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

Defined in Database.Beam.Query.Combinators

Methods

makeSQLOrdering :: (a, b, c) -> [WithExprContext syntax]

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

Defined in Database.Beam.Query.Combinators

Methods

makeSQLOrdering :: QOrd syntax s a -> [WithExprContext syntax]

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

Defined in Database.Beam.Query.Combinators

Methods

makeSQLOrdering :: (a, b, c, d) -> [WithExprContext syntax]

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

Defined in Database.Beam.Query.Combinators

Methods

makeSQLOrdering :: (a, b, c, d, e) -> [WithExprContext syntax]

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

Defined in Database.Beam.Query.Combinators

Methods

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

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

Defined in Database.Beam.Query.Combinators

Methods

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

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

Defined in Database.Beam.Query.Combinators

Methods

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

data QIfCond context expr s a Source #

data QIfElse context expr 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 select db. (ProjectibleInSelectSyntax select a, ThreadRewritable (QNested s) a) => Integer -> Q select db (QNested s) a -> Q select db s (WithRewrittenThread (QNested s) s a) Source #

Limit the number of results returned by a query.

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

Drop the first offset' results.

as_ :: forall a ctxt syntax s. QGenExpr ctxt syntax s a -> QGenExpr ctxt syntax 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_ :: (IsSql92SelectSyntax select, HasQBuilder select, ProjectibleInSelectSyntax select a, Sql92ExpressionSelectSyntax (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) ~ select) => Q select db s a -> QExpr (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) s Bool Source #

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

unique_ :: (IsSql92SelectSyntax select, HasQBuilder select, ProjectibleInSelectSyntax select a, Sql92ExpressionSelectSyntax (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) ~ select) => Q select db s a -> QExpr (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) s Bool Source #

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

distinct_ :: (IsSql99ExpressionSyntax (Sql92SelectExpressionSyntax select), HasQBuilder select, ProjectibleInSelectSyntax select a, Sql92ExpressionSelectSyntax (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) ~ select) => Q select db s a -> QExpr (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) s Bool Source #

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

Set operations

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

union_ :: forall select db s a. (IsSql92SelectSyntax select, Projectible (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) a, ProjectibleInSelectSyntax select a, ThreadRewritable (QNested s) a) => Q select db (QNested s) a -> Q select db (QNested s) a -> Q select db s (WithRewrittenThread (QNested s) s a) Source #

SQL UNION operator

unionAll_ :: forall select db s a. (IsSql92SelectSyntax select, Projectible (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) a, ProjectibleInSelectSyntax select a, ThreadRewritable (QNested s) a) => Q select db (QNested s) a -> Q select db (QNested s) a -> Q select db s (WithRewrittenThread (QNested s) s a) Source #

SQL UNION ALL operator

intersect_ :: forall select db s a. (IsSql92SelectSyntax select, Projectible (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) a, ProjectibleInSelectSyntax select a, ThreadRewritable (QNested s) a) => Q select db (QNested s) a -> Q select db (QNested s) a -> Q select db s (WithRewrittenThread (QNested s) s a) Source #

SQL INTERSECT operator

intersectAll_ :: forall select db s a. (IsSql92SelectSyntax select, Projectible (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) a, ProjectibleInSelectSyntax select a, ThreadRewritable (QNested s) a) => Q select db (QNested s) a -> Q select db (QNested s) a -> Q select db s (WithRewrittenThread (QNested s) s a) Source #

SQL INTERSECT ALL operator

except_ :: forall select db s a. (IsSql92SelectSyntax select, Projectible (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) a, ProjectibleInSelectSyntax select a, ThreadRewritable (QNested s) a) => Q select db (QNested s) a -> Q select db (QNested s) a -> Q select db s (WithRewrittenThread (QNested s) s a) Source #

SQL EXCEPT operator

exceptAll_ :: forall select db s a. (IsSql92SelectSyntax select, Projectible (Sql92SelectTableExpressionSyntax (Sql92SelectSelectTableSyntax select)) a, ProjectibleInSelectSyntax select a, ThreadRewritable (QNested s) a) => Q select db (QNested s) a -> Q select db (QNested s) a -> Q select db s (WithRewrittenThread (QNested s) s a) Source #

SQL EXCEPT ALL operator

Window functions

See the corresponding manual section for more.

over_ :: IsSql2003ExpressionSyntax syntax => QAgg syntax s a -> QWindow (Sql2003ExpressionWindowFrameSyntax syntax) s -> QWindowExpr syntax s a Source #

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

frame_ Source #

Specify a window frame with all the options

noOrder_ :: Maybe (QOrd syntax s Int) Source #

partitionBy_ :: partition -> Maybe partition Source #

orderPartitionBy_ :: partition -> Maybe partition Source #

withWindow_ Source #

Arguments

:: (ProjectibleWithPredicate WindowFrameContext (Sql2003ExpressionWindowFrameSyntax (Sql92SelectExpressionSyntax select)) window, Projectible (Sql92SelectExpressionSyntax select) r, Projectible (Sql92SelectExpressionSyntax select) a, ContextRewritable a, ThreadRewritable (QNested s) (WithRewrittenContext a QValueContext), IsSql92SelectSyntax select) 
=> (r -> window)

Window builder function

-> (r -> window -> a)

Projection builder function. Has access to the windows generated above

-> Q select db (QNested s) r

Query to window over

-> Q select 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 syntax db. (Projectible (Sql92SelectExpressionSyntax syntax) a, SqlOrderable (Sql92SelectOrderingSyntax syntax) ordering, ThreadRewritable (QNested s) a) => (a -> ordering) -> Q syntax db (QNested s) a -> Q syntax 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 syntax s a. IsSql92OrderingSyntax syntax => QExpr (Sql92OrderingExpressionSyntax syntax) s a -> QOrd syntax s a Source #

Produce a QOrd corresponding to a SQL ASC ordering

desc_ :: forall syntax s a. IsSql92OrderingSyntax syntax => QExpr (Sql92OrderingExpressionSyntax syntax) s a -> QOrd syntax s a Source #

Produce a QOrd corresponding to a SQL DESC ordering

Various combinators corresponding to SQL extensions

T614 NTILE function

ntile_ :: (Integral a, IsSql2003NtileExpressionSyntax syntax) => QExpr syntax s Int -> QAgg syntax s a Source #

T615 LEAD and LAG function

lead1_ :: IsSql2003LeadAndLagExpressionSyntax syntax => QExpr syntax s a -> QAgg syntax s a Source #

lag1_ :: IsSql2003LeadAndLagExpressionSyntax syntax => QExpr syntax s a -> QAgg syntax s a Source #

lead_ :: IsSql2003LeadAndLagExpressionSyntax syntax => QExpr syntax s a -> QExpr syntax s Int -> QAgg syntax s a Source #

lag_ :: IsSql2003LeadAndLagExpressionSyntax syntax => QExpr syntax s a -> QExpr syntax s Int -> QAgg syntax s a Source #

leadWithDefault_ :: IsSql2003LeadAndLagExpressionSyntax syntax => QExpr syntax s a -> QExpr syntax s Int -> QExpr syntax s a -> QAgg syntax s a Source #

lagWithDefault_ :: IsSql2003LeadAndLagExpressionSyntax syntax => QExpr syntax s a -> QExpr syntax s Int -> QExpr syntax s a -> QAgg syntax s a Source #

T616 FIRST_VALUE and LAST_VALUE functions

T618 NTH_VALUE function

nthValue_ :: IsSql2003NthValueExpressionSyntax syntax => QExpr syntax s a -> QExpr syntax s Int -> QAgg syntax s a Source #

T621 Enhanced numeric functions

(**.) :: (Floating a, IsSql2003EnhancedNumericFunctionsExpressionSyntax syntax) => QGenExpr ctxt syntax s a -> QGenExpr ctxt syntax s a -> QGenExpr ctxt syntax s a infixr 8 Source #

ln_ :: (Floating a, IsSql2003EnhancedNumericFunctionsExpressionSyntax syntax) => QGenExpr ctxt syntax s a -> QGenExpr ctxt syntax s a Source #

exp_ :: (Floating a, IsSql2003EnhancedNumericFunctionsExpressionSyntax syntax) => QGenExpr ctxt syntax s a -> QGenExpr ctxt syntax s a Source #

sqrt_ :: (Floating a, IsSql2003EnhancedNumericFunctionsExpressionSyntax syntax) => QGenExpr ctxt syntax s a -> QGenExpr ctxt syntax s a Source #

floor_ :: (RealFrac a, Integral b, IsSql2003EnhancedNumericFunctionsExpressionSyntax syntax) => QGenExpr ctxt syntax s a -> QGenExpr ctxt syntax s b Source #

covarPop_ :: (Num a, Floating b, IsSql2003EnhancedNumericFunctionsAggregationExpressionSyntax syntax) => QExpr syntax s a -> QExpr syntax s a -> QExpr syntax s b Source #

corr_ :: (Num a, Floating b, IsSql2003EnhancedNumericFunctionsAggregationExpressionSyntax syntax) => QExpr syntax s a -> QExpr syntax s a -> QExpr syntax s b Source #

regrAvgX_ :: (Num a, Floating b, IsSql2003EnhancedNumericFunctionsAggregationExpressionSyntax syntax) => QExpr syntax s a -> QExpr syntax s a -> QExpr syntax s b Source #

regrAvgY_ :: (Num a, Floating b, IsSql2003EnhancedNumericFunctionsAggregationExpressionSyntax syntax) => QExpr syntax s a -> QExpr syntax s a -> QExpr syntax s b Source #

regrSXX_ :: (Num a, Floating b, IsSql2003EnhancedNumericFunctionsAggregationExpressionSyntax syntax) => QExpr syntax s a -> QExpr syntax s a -> QExpr syntax s b Source #

regrSYY_ :: (Num a, Floating b, IsSql2003EnhancedNumericFunctionsAggregationExpressionSyntax syntax) => QExpr syntax s a -> QExpr syntax s a -> QExpr syntax s b Source #

regrSXY_ :: (Num a, Floating b, IsSql2003EnhancedNumericFunctionsAggregationExpressionSyntax syntax) => QExpr syntax s a -> QExpr syntax s a -> QExpr syntax s b Source #

Relationships

Many-to-many relationships

type ManyToMany db left right = forall syntax s. (Sql92SelectSanityCheck syntax, IsSql92SelectSyntax syntax, SqlEq (QExpr (Sql92SelectExpressionSyntax syntax) s) (PrimaryKey left (QExpr (Sql92SelectExpressionSyntax syntax) s)), SqlEq (QExpr (Sql92SelectExpressionSyntax syntax) s) (PrimaryKey right (QExpr (Sql92SelectExpressionSyntax syntax) s))) => Q syntax db s (left (QExpr (Sql92SelectExpressionSyntax syntax) s)) -> Q syntax db s (right (QExpr (Sql92SelectExpressionSyntax syntax) s)) -> Q syntax db s (left (QExpr (Sql92SelectExpressionSyntax syntax) s), right (QExpr (Sql92SelectExpressionSyntax syntax) s)) Source #

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

type ManyToManyThrough db through left right = forall syntax s. (Sql92SelectSanityCheck syntax, IsSql92SelectSyntax syntax, SqlEq (QExpr (Sql92SelectExpressionSyntax syntax) s) (PrimaryKey left (QExpr (Sql92SelectExpressionSyntax syntax) s)), SqlEq (QExpr (Sql92SelectExpressionSyntax syntax) s) (PrimaryKey right (QExpr (Sql92SelectExpressionSyntax syntax) s))) => Q syntax db s (left (QExpr (Sql92SelectExpressionSyntax syntax) s)) -> Q syntax db s (right (QExpr (Sql92SelectExpressionSyntax syntax) s)) -> Q syntax db s (through (QExpr (Sql92SelectExpressionSyntax syntax) s), left (QExpr (Sql92SelectExpressionSyntax syntax) s), right (QExpr (Sql92SelectExpressionSyntax syntax) 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, Sql92SelectSanityCheck syntax, IsSql92SelectSyntax syntax, SqlEq (QExpr (Sql92SelectExpressionSyntax syntax) s) (PrimaryKey left (QExpr (Sql92SelectExpressionSyntax syntax) s)), SqlEq (QExpr (Sql92SelectExpressionSyntax syntax) s) (PrimaryKey right (QExpr (Sql92SelectExpressionSyntax syntax) s))) => DatabaseEntity be db (TableEntity joinThrough) -> (joinThrough (QExpr (Sql92SelectExpressionSyntax syntax) s) -> PrimaryKey left (QExpr (Sql92SelectExpressionSyntax syntax) s)) -> (joinThrough (QExpr (Sql92SelectExpressionSyntax syntax) s) -> PrimaryKey right (QExpr (Sql92SelectExpressionSyntax syntax) s)) -> Q syntax db s (left (QExpr (Sql92SelectExpressionSyntax syntax) s)) -> Q syntax db s (right (QExpr (Sql92SelectExpressionSyntax syntax) s)) -> Q syntax db s (left (QExpr (Sql92SelectExpressionSyntax syntax) s), right (QExpr (Sql92SelectExpressionSyntax syntax) 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, Sql92SelectSanityCheck syntax, IsSql92SelectSyntax syntax, SqlEq (QExpr (Sql92SelectExpressionSyntax syntax) s) (PrimaryKey left (QExpr (Sql92SelectExpressionSyntax syntax) s)), SqlEq (QExpr (Sql92SelectExpressionSyntax syntax) s) (PrimaryKey right (QExpr (Sql92SelectExpressionSyntax syntax) s))) => DatabaseEntity be db (TableEntity joinThrough) -> (joinThrough (QExpr (Sql92SelectExpressionSyntax syntax) s) -> PrimaryKey left (QExpr (Sql92SelectExpressionSyntax syntax) s)) -> (joinThrough (QExpr (Sql92SelectExpressionSyntax syntax) s) -> PrimaryKey right (QExpr (Sql92SelectExpressionSyntax syntax) s)) -> Q syntax db s (left (QExpr (Sql92SelectExpressionSyntax syntax) s)) -> Q syntax db s (right (QExpr (Sql92SelectExpressionSyntax syntax) s)) -> Q syntax db s (joinThrough (QExpr (Sql92SelectExpressionSyntax syntax) s), left (QExpr (Sql92SelectExpressionSyntax syntax) s), right (QExpr (Sql92SelectExpressionSyntax syntax) 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 db s one many = forall syntax. (IsSql92SelectSyntax syntax, HasTableEquality (Sql92SelectExpressionSyntax syntax) (PrimaryKey one), HasSqlValueSyntax (Sql92ExpressionValueSyntax (Sql92SelectExpressionSyntax syntax)) Bool) => one (QExpr (Sql92SelectExpressionSyntax syntax) s) -> Q syntax db s (many (QExpr (Sql92SelectExpressionSyntax syntax) s)) Source #

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

type OneToManyOptional db s tbl rel = forall syntax. (IsSql92SelectSyntax syntax, HasTableEqualityNullable (Sql92SelectExpressionSyntax syntax) (PrimaryKey tbl), HasSqlValueSyntax (Sql92ExpressionValueSyntax (Sql92SelectExpressionSyntax syntax)) Bool, HasSqlValueSyntax (Sql92ExpressionValueSyntax (Sql92SelectExpressionSyntax syntax)) SqlNull) => tbl (QExpr (Sql92SelectExpressionSyntax syntax) s) -> Q syntax db s (rel (Nullable (QExpr (Sql92SelectExpressionSyntax syntax) 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

:: (IsSql92SelectSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax (Sql92SelectExpressionSyntax syntax)) Bool, Database be db, HasTableEquality (Sql92SelectExpressionSyntax syntax) (PrimaryKey tbl), Table tbl, Table rel) 
=> DatabaseEntity be db (TableEntity rel)

Table to fetch (many)

-> (rel (QExpr (Sql92SelectExpressionSyntax syntax) s) -> PrimaryKey tbl (QExpr (Sql92SelectExpressionSyntax syntax) s))

Foreign key

-> tbl (QExpr (Sql92SelectExpressionSyntax syntax) s) 
-> Q syntax db s (rel (QExpr (Sql92SelectExpressionSyntax syntax) 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

:: (IsSql92SelectSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax (Sql92SelectExpressionSyntax syntax)) Bool, HasSqlValueSyntax (Sql92ExpressionValueSyntax (Sql92SelectExpressionSyntax syntax)) SqlNull, HasTableEqualityNullable (Sql92SelectExpressionSyntax syntax) (PrimaryKey tbl), Database be db, Table tbl, Table rel) 
=> DatabaseEntity be db (TableEntity rel)

Table to fetch

-> (rel (QExpr (Sql92SelectExpressionSyntax syntax) s) -> PrimaryKey tbl (Nullable (QExpr (Sql92SelectExpressionSyntax syntax) s)))

Foreign key

-> tbl (QExpr (Sql92SelectExpressionSyntax syntax) s) 
-> Q syntax db s (rel (Nullable (QExpr (Sql92SelectExpressionSyntax syntax) 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 db s one many = OneToMany 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 db s tbl rel = OneToManyOptional 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

:: (IsSql92SelectSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax (Sql92SelectExpressionSyntax syntax)) Bool, Database be db, HasTableEquality (Sql92SelectExpressionSyntax syntax) (PrimaryKey tbl), Table tbl, Table rel) 
=> DatabaseEntity be db (TableEntity rel)

Table to fetch (many)

-> (rel (QExpr (Sql92SelectExpressionSyntax syntax) s) -> PrimaryKey tbl (QExpr (Sql92SelectExpressionSyntax syntax) s))

Foreign key

-> tbl (QExpr (Sql92SelectExpressionSyntax syntax) s) 
-> Q syntax db s (rel (QExpr (Sql92SelectExpressionSyntax syntax) 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

:: (IsSql92SelectSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax (Sql92SelectExpressionSyntax syntax)) Bool, HasSqlValueSyntax (Sql92ExpressionValueSyntax (Sql92SelectExpressionSyntax syntax)) SqlNull, HasTableEqualityNullable (Sql92SelectExpressionSyntax syntax) (PrimaryKey tbl), Database be db, Table tbl, Table rel) 
=> DatabaseEntity be db (TableEntity rel)

Table to fetch

-> (rel (QExpr (Sql92SelectExpressionSyntax syntax) s) -> PrimaryKey tbl (Nullable (QExpr (Sql92SelectExpressionSyntax syntax) s)))

Foreign key

-> tbl (QExpr (Sql92SelectExpressionSyntax syntax) s) 
-> Q syntax db s (rel (Nullable (QExpr (Sql92SelectExpressionSyntax syntax) 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.

Operators

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

SQL AND operator

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

SQL OR operator

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

SQL AND operator for SqlBool

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

SQL OR operator

like_ :: (IsSqlExpressionSyntaxStringType syntax text, IsSql92ExpressionSyntax syntax) => QExpr syntax s text -> QExpr syntax s text -> QExpr syntax s Bool infix 4 Source #

SQL LIKE operator

similarTo_ :: (IsSqlExpressionSyntaxStringType syntax text, IsSql99ExpressionSyntax syntax) => QExpr syntax s text -> QExpr syntax s text -> QExpr syntax s text infix 4 Source #

SQL99 SIMILAR TO operator

not_ :: forall syntax context s. IsSql92ExpressionSyntax syntax => QGenExpr context syntax s Bool -> QGenExpr context syntax s Bool Source #

SQL NOT operator

sqlNot_ :: forall syntax context s. IsSql92ExpressionSyntax syntax => QGenExpr context syntax s SqlBool -> QGenExpr context syntax s SqlBool Source #

SQL NOT operator, but operating on SqlBool instead

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

SQL / operator

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

SQL % operator

concat_ :: IsSql99ConcatExpressionSyntax syntax => [QGenExpr context syntax s Text] -> QGenExpr context syntax 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_ :: IsSql92ExpressionSyntax syntax => QGenExpr context syntax s SqlBool -> QGenExpr context syntax s Bool Source #

SQL IS TRUE operator

isNotTrue_ :: IsSql92ExpressionSyntax syntax => QGenExpr context syntax s SqlBool -> QGenExpr context syntax s Bool Source #

SQL IS NOT TRUE operator

isFalse_ :: IsSql92ExpressionSyntax syntax => QGenExpr context syntax s SqlBool -> QGenExpr context syntax s Bool Source #

SQL IS FALSE operator

isNotFalse_ :: IsSql92ExpressionSyntax syntax => QGenExpr context syntax s SqlBool -> QGenExpr context syntax s Bool Source #

SQL IS NOT FALSE operator

isUnknown_ :: IsSql92ExpressionSyntax syntax => QGenExpr context syntax s SqlBool -> QGenExpr context syntax s Bool Source #

SQL IS UNKNOWN operator

isNotUnknown_ :: IsSql92ExpressionSyntax syntax => QGenExpr context syntax s SqlBool -> QGenExpr context syntax s Bool Source #

SQL IS NOT UNKNOWN operator

unknownAs_ :: IsSql92ExpressionSyntax syntax => Bool -> QGenExpr context syntax s SqlBool -> QGenExpr context syntax 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

Unquantified comparison operators

class (IsSql92ExpressionSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) Bool) => HasSqlEqualityCheck syntax a where Source #

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

Minimal complete definition

Nothing

Methods

sqlEqE :: Proxy a -> syntax -> syntax -> syntax Source #

sqlNeqE :: Proxy a -> syntax -> syntax -> syntax Source #

sqlEqTriE :: Proxy a -> syntax -> syntax -> syntax Source #

Tri-state equality

sqlNeqTriE :: Proxy a -> syntax -> syntax -> syntax Source #

Tri-state equality

Instances
HasSqlEqualityCheck Expression Bool Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck Expression Double Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck Expression Float Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck Expression Int Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck Expression Int8 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck Expression Int16 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck Expression Int32 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck Expression Int64 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck Expression Integer Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck Expression Word Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck Expression Word8 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck Expression Word16 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck Expression Word32 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck Expression Word64 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck Expression Text Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck Expression UTCTime Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck Expression LocalTime Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck Expression TimeOfDay Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck Expression Day Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck SqlSyntaxBuilder Bool Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck SqlSyntaxBuilder Double Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck SqlSyntaxBuilder Float Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck SqlSyntaxBuilder Int Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck SqlSyntaxBuilder Int8 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck SqlSyntaxBuilder Int16 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck SqlSyntaxBuilder Int32 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck SqlSyntaxBuilder Int64 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck SqlSyntaxBuilder Integer Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck SqlSyntaxBuilder Word Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck SqlSyntaxBuilder Word8 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck SqlSyntaxBuilder Word16 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck SqlSyntaxBuilder Word32 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck SqlSyntaxBuilder Word64 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck SqlSyntaxBuilder Text Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck SqlSyntaxBuilder UTCTime Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck SqlSyntaxBuilder LocalTime Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck SqlSyntaxBuilder TimeOfDay Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck SqlSyntaxBuilder Day Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck syntax a => HasSqlEqualityCheck syntax (SqlSerial a) Source # 
Instance details

Defined in Database.Beam.Query.Ord

Methods

sqlEqE :: Proxy (SqlSerial a) -> syntax -> syntax -> syntax Source #

sqlNeqE :: Proxy (SqlSerial a) -> syntax -> syntax -> syntax Source #

sqlEqTriE :: Proxy (SqlSerial a) -> syntax -> syntax -> syntax Source #

sqlNeqTriE :: Proxy (SqlSerial a) -> syntax -> syntax -> syntax Source #

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

Defined in Database.Beam.Query.Ord

Methods

sqlEqE :: Proxy (Maybe a) -> syntax -> syntax -> syntax Source #

sqlNeqE :: Proxy (Maybe a) -> syntax -> syntax -> syntax Source #

sqlEqTriE :: Proxy (Maybe a) -> syntax -> syntax -> syntax Source #

sqlNeqTriE :: Proxy (Maybe a) -> syntax -> syntax -> syntax Source #

HasSqlEqualityCheck Expression a => HasSqlEqualityCheck Expression (Tagged t a) Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlEqualityCheck SqlSyntaxBuilder a => HasSqlEqualityCheck SqlSyntaxBuilder (Tagged t a) Source # 
Instance details

Defined in Database.Beam.Query.Ord

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

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

Minimal complete definition

Nothing

Methods

sqlQEqE :: Proxy a -> Maybe (Sql92ExpressionQuantifierSyntax syntax) -> syntax -> syntax -> syntax Source #

sqlQNeqE :: Proxy a -> Maybe (Sql92ExpressionQuantifierSyntax syntax) -> syntax -> syntax -> syntax Source #

Instances
HasSqlQuantifiedEqualityCheck Expression Bool Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck Expression Double Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck Expression Float Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck Expression Int Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck Expression Int8 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck Expression Int16 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck Expression Int32 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck Expression Int64 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck Expression Integer Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck Expression Word Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck Expression Word8 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck Expression Word16 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck Expression Word32 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck Expression Word64 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck Expression Text Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck Expression UTCTime Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck Expression LocalTime Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck Expression TimeOfDay Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck Expression Day Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck SqlSyntaxBuilder Bool Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck SqlSyntaxBuilder Double Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck SqlSyntaxBuilder Float Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck SqlSyntaxBuilder Int Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck SqlSyntaxBuilder Int8 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck SqlSyntaxBuilder Int16 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck SqlSyntaxBuilder Int32 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck SqlSyntaxBuilder Int64 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck SqlSyntaxBuilder Integer Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck SqlSyntaxBuilder Word Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck SqlSyntaxBuilder Word8 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck SqlSyntaxBuilder Word16 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck SqlSyntaxBuilder Word32 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck SqlSyntaxBuilder Word64 Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck SqlSyntaxBuilder Text Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck SqlSyntaxBuilder UTCTime Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck SqlSyntaxBuilder LocalTime Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck SqlSyntaxBuilder TimeOfDay Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck SqlSyntaxBuilder Day Source # 
Instance details

Defined in Database.Beam.Query.Ord

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

Defined in Database.Beam.Query.Ord

Methods

sqlQEqE :: Proxy (SqlSerial a) -> Maybe (Sql92ExpressionQuantifierSyntax syntax) -> syntax -> syntax -> syntax Source #

sqlQNeqE :: Proxy (SqlSerial a) -> Maybe (Sql92ExpressionQuantifierSyntax syntax) -> syntax -> syntax -> syntax Source #

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

Defined in Database.Beam.Query.Ord

Methods

sqlQEqE :: Proxy (Maybe a) -> Maybe (Sql92ExpressionQuantifierSyntax syntax) -> syntax -> syntax -> syntax Source #

sqlQNeqE :: Proxy (Maybe a) -> Maybe (Sql92ExpressionQuantifierSyntax syntax) -> syntax -> syntax -> syntax Source #

HasSqlQuantifiedEqualityCheck Expression a => HasSqlQuantifiedEqualityCheck Expression (Tagged t a) Source # 
Instance details

Defined in Database.Beam.Query.Ord

HasSqlQuantifiedEqualityCheck SqlSyntaxBuilder a => HasSqlQuantifiedEqualityCheck SqlSyntaxBuilder (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
(IsSql92ExpressionSyntax syntax, FieldsFulfillConstraintNullable (HasSqlEqualityCheck syntax) tbl, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) Bool, Beamable tbl) => SqlEq (QGenExpr context syntax s) (tbl (Nullable (QGenExpr context syntax s))) Source # 
Instance details

Defined in Database.Beam.Query.Ord

Methods

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

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

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

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

(IsSql92ExpressionSyntax syntax, FieldsFulfillConstraint (HasSqlEqualityCheck syntax) tbl, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) Bool, Beamable tbl) => SqlEq (QGenExpr context syntax s) (tbl (QGenExpr context syntax s)) Source #

Compare two arbitrary Beamable types containing QGenExprs for equality.

Instance details

Defined in Database.Beam.Query.Ord

Methods

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

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

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

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

(IsSql92ExpressionSyntax syntax, HasSqlEqualityCheck syntax a) => SqlEq (QGenExpr context syntax s) (QGenExpr context syntax s a) Source #

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

Instance details

Defined in Database.Beam.Query.Ord

Methods

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

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

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

(/=?.) :: QGenExpr context syntax s a -> QGenExpr context syntax s a -> QGenExpr context syntax 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
IsSql92ExpressionSyntax syntax => SqlOrd (QGenExpr context syntax s) (QGenExpr context syntax s a) Source # 
Instance details

Defined in Database.Beam.Query.Ord

Methods

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

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

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

(>=.) :: QGenExpr context syntax s a -> QGenExpr context syntax s a -> QGenExpr context syntax 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
(IsSql92ExpressionSyntax syntax, HasSqlQuantifiedEqualityCheck syntax a) => SqlEqQuantified (QGenExpr context syntax s) (QQuantified syntax s a) (QGenExpr context syntax s a) Source #

Two arbitrary expressions can be quantifiably compared for equality.

Instance details

Defined in Database.Beam.Query.Ord

Methods

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

(/=*.) :: QGenExpr context syntax s a -> QQuantified syntax s a -> QGenExpr context syntax 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
IsSql92ExpressionSyntax syntax => SqlOrdQuantified (QGenExpr context syntax s) (QQuantified syntax s a) (QGenExpr context syntax s a) Source # 
Instance details

Defined in Database.Beam.Query.Ord

Methods

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

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

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

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

data QQuantified expr s r Source #

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

Instances
IsSql92ExpressionSyntax syntax => SqlOrdQuantified (QGenExpr context syntax s) (QQuantified syntax s a) (QGenExpr context syntax s a) Source # 
Instance details

Defined in Database.Beam.Query.Ord

Methods

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

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

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

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

(IsSql92ExpressionSyntax syntax, HasSqlQuantifiedEqualityCheck syntax a) => SqlEqQuantified (QGenExpr context syntax s) (QQuantified syntax s a) (QGenExpr context syntax s a) Source #

Two arbitrary expressions can be quantifiably compared for equality.

Instance details

Defined in Database.Beam.Query.Ord

Methods

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

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

anyOf_ :: forall s a select expr db. (IsSql92SelectSyntax select, IsSql92ExpressionSyntax expr, HasQBuilder select, Sql92ExpressionSelectSyntax expr ~ select) => Q select db (QNested s) (QExpr (Sql92SelectExpressionSyntax select) (QNested s) a) -> QQuantified expr 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 select expr db. (IsSql92SelectSyntax select, IsSql92ExpressionSyntax expr, HasQBuilder select, Sql92ExpressionSelectSyntax expr ~ select) => Q select db (QNested s) (QExpr (Sql92SelectExpressionSyntax select) (QNested s) a) -> QQuantified expr 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 expr. IsSql92ExpressionSyntax expr => [QExpr expr s a] -> QQuantified expr 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 expr. IsSql92ExpressionSyntax expr => [QExpr expr s a] -> QQuantified expr 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_ :: IsSql92ExpressionSyntax syntax => QGenExpr context syntax s a -> QGenExpr context syntax s a -> QGenExpr context syntax s a -> QGenExpr context syntax s Bool infix 4 Source #

SQL BETWEEN clause

in_ :: (IsSql92ExpressionSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) Bool) => QGenExpr context syntax s a -> [QGenExpr context syntax s a] -> QGenExpr context syntax s Bool infix 4 Source #

SQL IN predicate

Aggregates

See the corresponding manual section for more detail

aggregate_ Source #

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_ :: IsSql2003ExpressionElementaryOLAPOperationsSyntax expr => QAgg expr s a -> QExpr expr s Bool -> QAgg expr s a Source #

Support for FILTER (WHERE ...) syntax for aggregates. Part of SQL2003 Advanced OLAP operations feature (T612).

See filterWhere_' for a version that accepts 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 (QExpr expr s)) (tbl (QGroupExpr expr 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 expr s) -> tbl (QGroupExpr expr s) Source #

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

group_ for simple value expressions.

Instance details

Defined in Database.Beam.Query.Aggregate

Methods

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

General-purpose aggregate functions

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

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

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

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

min_ :: IsSql92AggregationExpressionSyntax expr => QExpr expr s a -> QAgg expr s (Maybe a) Source #

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