beam-core-0.9.2.1: Type-safe, feature-complete SQL query and manipulation interface for Haskell
Safe Haskell None
Language Haskell2010

Database.Beam.Query

Synopsis

Query type

type QExpr = QGenExpr QValueContext Source #

QExpr s represent expressions not containing aggregates.

newtype QGenExpr context be s t Source #

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

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

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

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

Instances

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

Defined in Database.Beam.Query.Internal

Methods

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

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

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

Defined in Database.Beam.Query.Internal

Methods

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

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

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

Defined in Database.Beam.Query.Internal

Methods

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

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

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

Defined in Database.Beam.Query.Internal

Associated Types

type WithRewrittenThread s s' (tbl ( Nullable ( QGenExpr ctxt syntax s))) 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)) Source #

Methods

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

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

Defined in Database.Beam.Query.Combinators

Methods

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

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

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

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

Defined in Database.Beam.Query.Internal

Associated Types

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

Methods

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

( TypeError (' Text "Missing mandatory sorting order. Use either 'asc_' or 'desc_' to specify sorting order.") :: Constraint ) => SqlOrderable be ( QGenExpr ctx be s a) Source #
Instance details

Defined in Database.Beam.Query.Combinators

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

Defined in Database.Beam.Query.Combinators

Methods

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

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

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

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

Defined in Database.Beam.Query.Internal

Associated Types

type WithRewrittenContext (tbl ( Nullable ( QGenExpr old syntax s))) ctxt 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 Source #

Methods

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

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

Defined in Database.Beam.Query.Combinators

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

Defined in Database.Beam.Query.Combinators

Methods

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

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

Defined in Database.Beam.Query.Combinators

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

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

Instance details

Defined in Database.Beam.Query.Aggregate

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

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

Instance details

Defined in Database.Beam.Query.Aggregate

Methods

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

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

Defined in Database.Beam.Query.Combinators

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

Defined in Database.Beam.Query.Ord

Methods

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

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

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

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

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

Compare two arbitrary Beamable types containing QGenExpr s for equality.

Instance details

Defined in Database.Beam.Query.Ord

Methods

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

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

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

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

( HasSqlInTable be, Beamable table) => SqlIn ( QGenExpr context be s) (table ( QGenExpr context be s)) Source #
Instance details

Defined in Database.Beam.Query.Ord

Methods

in_ :: table ( QGenExpr context be s) -> [table ( QGenExpr context be s)] -> QGenExpr context be s Bool Source #

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

Defined in Database.Beam.Query.Combinators

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

group_ for simple value expressions.

Instance details

Defined in Database.Beam.Query.Aggregate

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

Defined in Database.Beam.Query.Ord

Methods

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

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

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

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

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

Two arbitrary expressions can be quantifiably compared for equality.

Instance details

Defined in Database.Beam.Query.Ord

Methods

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

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

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

Defined in Database.Beam.Query.Internal

Associated Types

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

Methods

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

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

Defined in Database.Beam.Query.Ord

Methods

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

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

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

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

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

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

Instance details

Defined in Database.Beam.Query.Ord

Methods

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

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

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

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

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

Defined in Database.Beam.Query.Ord

Methods

in_ :: QGenExpr context be s a -> [ QGenExpr context be s a] -> QGenExpr context be s Bool Source #

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

Defined in Database.Beam.Query.Internal

Methods

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

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

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

Defined in Database.Beam.Query.Internal

Methods

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

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

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

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

Defined in Database.Beam.Query.Internal

Methods

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

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

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

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

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

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

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

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

Defined in Database.Beam.Query.Internal

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 Source #

Methods

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

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

Defined in Database.Beam.Query.Combinators

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

Defined in Database.Beam.Query.Internal

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

Defined in Database.Beam.Query.Internal

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

Defined in Database.Beam.Query.Internal

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

Defined in Database.Beam.Query.Internal

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

Defined in Database.Beam.Query.Types

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

Defined in Database.Beam.Query.Types

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

Defined in Database.Beam.Query.Types

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

Defined in Database.Beam.Query.Combinators

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

Defined in Database.Beam.Query.Internal

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

Defined in Database.Beam.Query.Internal

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

Defined in Database.Beam.Query.Types

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

Defined in Database.Beam.Query.Types

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

Defined in Database.Beam.Query.Combinators

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

Defined in Database.Beam.Query.Internal

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

data Q be (db :: ( Type -> Type ) -> Type ) 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 QExpr s. syntax represents the SQL syntax that this query is building.

Instances

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

Defined in Database.Beam.Query.Internal

Methods

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

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

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

Functor ( Q be db s) Source #
Instance details

Defined in Database.Beam.Query.Internal

Methods

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

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

Applicative ( Q be db s) Source #
Instance details

Defined in Database.Beam.Query.Internal

Methods

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

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

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

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

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

type family QExprToField x Source #

Instances

Instances details
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

Instances details
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 ( 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, QExpr corresponds to QGenExpr s that result in values. In reality, QExpr is really QGenExpr parameterized over the QValueContext . Similarly, QAgg represents expressions that contain aggregates, but it is just QGenExpr parameterized over QAggregateContext

data QGroupingContext Source #

Instances

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

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

Instance details

Defined in Database.Beam.Query.Aggregate

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

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

Instance details

Defined in Database.Beam.Query.Aggregate

Methods

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

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

group_ for simple value expressions.

Instance details

Defined in Database.Beam.Query.Aggregate

type ContextName QGroupingContext Source #
Instance details

Defined in Database.Beam.Query.Internal

type ContextName QGroupingContext = "an aggregate grouping"

data QValueContext Source #

Instances

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

Defined in Database.Beam.Query.Combinators

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

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

Instance details

Defined in Database.Beam.Query.Aggregate

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

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

Instance details

Defined in Database.Beam.Query.Aggregate

Methods

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

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

Defined in Database.Beam.Query.Combinators

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

Defined in Database.Beam.Query.Combinators

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

group_ for simple value expressions.

Instance details

Defined in Database.Beam.Query.Aggregate

type ContextName QValueContext Source #
Instance details

Defined in Database.Beam.Query.Internal

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

A version of the table where each field is a QGenExpr

data QField s ty Source #

Instances

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

Defined in Database.Beam.Query.Internal

Methods

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

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

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

Defined in Database.Beam.Query.Internal

Methods

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

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

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

Defined in Database.Beam.Query.Internal

Methods

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

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

Eq ( QField s ty) Source #
Instance details

Defined in Database.Beam.Query.Internal

Ord ( QField s ty) Source #
Instance details

Defined in Database.Beam.Query.Internal

Show ( QField s ty) Source #
Instance details

Defined in Database.Beam.Query.Internal

Various SQL functions and constructs

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

SQL COALESCE support

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

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

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

SQL POSITION(.. IN ..) function

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

SQL CHAR_LENGTH function

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

SQL OCTET_LENGTH function

bitLength_ :: ( BeamSqlBackend be, Integral a) => QGenExpr context be s SqlBitString -> QGenExpr context be s a Source #

SQL BIT_LENGTH function

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

SQL CURRENT_TIMESTAMP function

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

SQL LOWER function

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

SQL UPPER function

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

SQL TRIM function

IF-THEN-ELSE support

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

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

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

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

ifThenElse_ :: BeamSqlBackend be => QGenExpr context be s Bool -> QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s a Source #

bool_ :: BeamSqlBackend be => QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool -> QGenExpr context be s a Source #

SQL UPDATE assignments

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

Update a QField or Beamable type containing QField s with the given QExpr or Beamable type containing QExpr

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

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

Project Haskell values to QGenExpr s

type family HaskellLiteralForQExpr x = a Source #

Instances

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

Defined in Database.Beam.Query.Combinators

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

Defined in Database.Beam.Query.Combinators

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

Defined in Database.Beam.Query.Combinators

type HaskellLiteralForQExpr ( QGenExpr context be s a) = a

General query combinators

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

Introduce all entries of a table into the Q monad

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

SQL VALUES clause. Introduce the elements of the given list as rows in a joined table.

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

Introduce all entries of a view into the Q monad

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

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

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

Like join_ , but accepting an ON condition that returns SqlBool

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

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

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

Only allow results for which the QExpr yields TRUE .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Generate an appropriate boolean QGenExpr comparing the given foreign key to the given table. Useful for creating join conditions. Use references_' for a SqlBool comparison.

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

Generate an appropriate boolean QGenExpr comparing the given foreign key to the given table. Useful for creating join conditions. Use references_ for a Bool comparison.

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

Only return distinct values from a query

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

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

Methods

just_ :: a -> b Source #

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

nothing_ :: b Source #

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

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

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

Methods

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

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

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

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

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

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

Instances

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

Defined in Database.Beam.Query.Combinators

Methods

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

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

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

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

Defined in Database.Beam.Query.Combinators

Methods

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

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

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

class SqlOrderable be a | a -> be Source #

Minimal complete definition

makeSQLOrdering

Instances

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

Defined in Database.Beam.Query.Combinators

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

Defined in Database.Beam.Query.Combinators

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

Defined in Database.Beam.Query.Combinators

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

Defined in Database.Beam.Query.Combinators

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

Defined in Database.Beam.Query.Combinators

( TypeError (' Text "Missing mandatory sorting order. Use either 'asc_' or 'desc_' to specify sorting order.") :: Constraint ) => SqlOrderable be ( QGenExpr ctx be s a) Source #
Instance details

Defined in Database.Beam.Query.Combinators

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

Defined in Database.Beam.Query.Combinators

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

Defined in Database.Beam.Query.Combinators

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

Defined in Database.Beam.Query.Combinators

Methods

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

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

Defined in Database.Beam.Query.Combinators

Methods

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

data QIfCond context be s a Source #

data QIfElse context be s a Source #

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

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

Limit the number of results returned by a query.

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

Drop the first offset ` results.

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

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

Useful to disambiguate the types of QGenExpr s 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_ @Int32 countAll_) ..

Subqueries

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

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

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

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

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

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

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

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

Set operations

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

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

SQL UNION operator

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

SQL UNION ALL operator

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

SQL INTERSECT operator

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

SQL INTERSECT ALL operator

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

SQL EXCEPT operator

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

SQL EXCEPT ALL operator

Window functions

See the corresponding manual section for more.

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

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

frame_ Source #

Arguments

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

PARTITION BY

-> Maybe ordering

ORDER BY

-> QFrameBounds be

RANGE / ROWS

-> QWindow be s

Specify a window frame with all the options

partitionBy_ :: partition -> Maybe partition Source #

withWindow_ Source #

Arguments

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

Window builder function

-> (r -> window -> a)

Projection builder function. Has access to the windows generated above

-> Q be db ( QNested s) r

Query to window over

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

Compute a query over windows.

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

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

Ordering primitives

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

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

The manual section has more information.

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

Produce a QOrd corresponding to a SQL ASC ordering

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

Produce a QOrd corresponding to a SQL DESC ordering

Various combinators corresponding to SQL extensions

T614 NTILE function

T615 LEAD and LAG function

T616 FIRST_VALUE and LAST_VALUE functions

T618 NTH_VALUE function

T621 Enhanced numeric functions

Relationships

Many-to-many relationships

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

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

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

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

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

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

See the manual for more information.

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

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

See the manual for more information.

One-to-many relationships

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

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

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

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

oneToMany_ Source #

Arguments

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

Table to fetch (many)

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

Foreign key

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

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

oneToManyOptional_ Source #

Arguments

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

Table to fetch

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

Foreign key

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

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

One-to-one relationshships

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

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

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

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

oneToOne_ Source #

Arguments

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

Table to fetch (many)

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

Foreign key

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

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

oneToMaybe_ Source #

Arguments

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

Table to fetch

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

Foreign key

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

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

data ReusableQ be db res Source #

Query results that have been introduced into a common table expression via selecting that can be used in future queries with reuse .

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

Monad in which SELECT statements can be made (via selecting ) and bound to result names for re-use later. This has the advantage of only computing each result once. In SQL, this is translated to a common table expression.

Once introduced, results can be re-used in future queries with reuse .

With is also a member of MonadFix for backends that support recursive CTEs. In this case, you can use mdo or rec notation (with RecursiveDo enabled) to bind result values (again, using reuse ) even before they're introduced.

See further documentation here .

Instances

Instances details
Monad ( With be db) Source #
Instance details

Defined in Database.Beam.Query.CTE

Methods

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

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

return :: a -> With be db a Source #

Functor ( With be db) Source #
Instance details

Defined in Database.Beam.Query.CTE

Methods

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

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

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

Defined in Database.Beam.Query.CTE

Methods

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

Applicative ( With be db) Source #
Instance details

Defined in Database.Beam.Query.CTE

Methods

pure :: a -> With be db a Source #

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

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

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

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

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

Introduce the result of a query as a result in a common table expression. The returned value can be used in future queries by applying reuse .

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

Introduces the result of a previous selecting (a CTE) into a new query

SQL EXTRACT support

newtype ExtractField be tgt a Source #

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

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

Extracts the given field from the target expression

SQL92 fields

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

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

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

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

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

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

class HasSqlTime tgt Source #

Type-class for types that contain a time component

class HasSqlDate tgt Source #

Type-class for types that contain a date component

Operators

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.

General-purpose operators

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

SQL AND operator

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

SQL OR operator

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

SQL NOT operator

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

SQL / operator

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

SQL % operator

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

SQL AND operator for SqlBool

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

SQL OR operator

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

SQL NOT operator, but operating on SqlBool instead

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

SQL LIKE operator

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

SQL99 SIMILAR TO operator

like_' :: ( BeamSqlBackendIsString be left, BeamSqlBackendIsString be right, BeamSqlBackend be) => QGenExpr ctxt be s left -> QGenExpr ctxt be s right -> QGenExpr ctxt be s Bool Source #

SQL LIKE operator but heterogeneous over the text type

similarTo_' :: ( BeamSqlBackendIsString be left, BeamSqlBackendIsString be right, BeamSql99ExpressionBackend be) => QGenExpr ctxt be s left -> QGenExpr ctxt be s right -> QGenExpr ctxt be s left Source #

SQL99 SIMILAR TO operator but heterogeneous over the text type

ANSI SQL Booleans

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

SQL IS TRUE operator

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

SQL IS NOT TRUE operator

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

SQL IS FALSE operator

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

SQL IS NOT FALSE operator

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

SQL IS UNKNOWN operator

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

SQL IS NOT UNKNOWN operator

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

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

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

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

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

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

Unquantified comparison operators

class BeamSqlBackend be => HasSqlEqualityCheck be a where Source #

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

Minimal complete definition

Nothing

Instances

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

Defined in Database.Beam.Query.Ord

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

Defined in Database.Beam.Query.Ord

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

Defined in Database.Beam.Query.Ord

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

Defined in Database.Beam.Query.Ord

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

Defined in Database.Beam.Query.Ord

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

Defined in Database.Beam.Query.Ord