Safe Haskell | None |
---|---|
Language | Haskell2010 |
This builds on TsWeb.Types.Db's read-only/read-write discrimination by
providing query functions to perform read-only operations, and an execute
function to run updates, inserts, and deletes (and also selects as
appropriate). All of these are performed as TsActionCtxT
actions
so as to nicely integrate with Spock. Finally, because I'm not a fan of
exceptions, all of these functions trap Postgres errors and convert them into
sum-type results.
I'm not yet providing shortcuts for the beam-postgres specific functions. I'm not actually sure that I need to (IIRC they all build Pg actions), but I will be adding them if necessary.
Synopsis
- class Typeable (a :: k)
- class Generic a
- class Monad m => MonadIO (m :: Type -> Type) where
- data Identity a
- runDelete :: (BeamSqlBackend be, MonadBeam be m) => SqlDelete be table -> m ()
- delete :: BeamSqlBackend be => DatabaseEntity be db (TableEntity table) -> (forall s. (forall s'. table (QExpr be s')) -> QExpr be s Bool) -> SqlDelete be table
- runUpdate :: (BeamSqlBackend be, MonadBeam be m) => SqlUpdate be tbl -> m ()
- save :: (Table table, BeamSqlBackend be, SqlValableTable be (PrimaryKey table), SqlValableTable be table, HasTableEquality be (PrimaryKey table)) => DatabaseEntity be db (TableEntity table) -> table Identity -> SqlUpdate be table
- toUpdatedValueMaybe :: (forall s. table (QExpr be s) -> Maybe (QExpr be s a)) -> QFieldAssignment be table a
- toUpdatedValue :: (forall s. table (QExpr be s) -> QExpr be s a) -> QFieldAssignment be table a
- toOldValue :: QFieldAssignment be table a
- toNewValue :: (forall s. QExpr be s a) -> QFieldAssignment be table a
- setFieldsTo :: Table table => (forall s. table (QExpr be s)) -> table (QFieldAssignment be table')
- set :: Beamable table => table (QFieldAssignment be table')
- updateTableRow :: (BeamSqlBackend be, Table table, HasTableEquality be (PrimaryKey table), SqlValableTable be (PrimaryKey table)) => DatabaseEntity be db (TableEntity table) -> table Identity -> table (QFieldAssignment be table) -> SqlUpdate be table
- updateTable :: (BeamSqlBackend be, Beamable table) => DatabaseEntity be db (TableEntity table) -> table (QFieldAssignment be table) -> (forall s. table (QExpr be s) -> QExpr be s Bool) -> SqlUpdate be table
- updateRow :: (BeamSqlBackend be, Table table, HasTableEquality be (PrimaryKey table), SqlValableTable be (PrimaryKey table)) => DatabaseEntity be db (TableEntity table) -> table Identity -> (forall s. table (QField s) -> QAssignment be s) -> SqlUpdate be table
- update :: (BeamSqlBackend be, Beamable table) => DatabaseEntity be db (TableEntity table) -> (forall s. table (QField s) -> QAssignment be s) -> (forall s. table (QExpr be s) -> QExpr be s Bool) -> SqlUpdate be table
- insertFrom :: (BeamSqlBackend be, HasQBuilder be, Projectible be r) => Q be db QBaseScope r -> SqlInsertValues be r
- insertData :: (Projectible be r, BeamSqlBackend be) => [r] -> SqlInsertValues be r
- insertValues :: (BeamSqlBackend be, Beamable table, FieldsFulfillConstraint (BeamSqlBackendCanSerialize be) table) => [table Identity] -> SqlInsertValues be (table (QExpr be s))
- insertExpressions :: (BeamSqlBackend be, Beamable table) => (forall s'. [table (QExpr be s')]) -> SqlInsertValues be (table (QExpr be s))
- runInsert :: (BeamSqlBackend be, MonadBeam be m) => SqlInsert be table -> m ()
- insert :: (BeamSqlBackend be, ProjectibleWithPredicate AnyType () Text (table (QField s))) => DatabaseEntity be db (TableEntity table) -> SqlInsertValues be (table (QExpr be s)) -> SqlInsert be table
- insertOnly :: (BeamSqlBackend be, ProjectibleWithPredicate AnyType () Text (QExprToField r)) => DatabaseEntity be db (TableEntity table) -> (table (QField s) -> QExprToField r) -> SqlInsertValues be r -> SqlInsert be table
- dumpSqlSelect :: Projectible (MockSqlBackend SqlSyntaxBuilder) res => Q (MockSqlBackend SqlSyntaxBuilder) db QBaseScope res -> IO ()
- lookup_ :: (Database be db, Table table, BeamSqlBackend be, HasQBuilder be, SqlValableTable be (PrimaryKey table), HasTableEquality be (PrimaryKey table)) => DatabaseEntity be db (TableEntity table) -> PrimaryKey table Identity -> SqlSelect be (table Identity)
- selectWith :: (BeamSqlBackend be, BeamSql99CommonTableExpressionBackend be, HasQBuilder be, Projectible be res) => With be db (Q be db QBaseScope res) -> SqlSelect be (QExprToIdentity res)
- select :: (BeamSqlBackend be, HasQBuilder be, Projectible be res) => Q be db QBaseScope res -> SqlSelect be (QExprToIdentity res)
- data QBaseScope
- type QGenExprTable ctxt be s (tbl :: (Type -> Type) -> Type) = tbl (QGenExpr ctxt be s)
- type QExprTable be s (tbl :: (Type -> Type) -> Type) = QGenExprTable QValueContext be s tbl
- newtype SqlSelect be a = SqlSelect (BeamSqlBackendSelectSyntax be)
- data SqlInsert be (table :: (Type -> Type) -> Type)
- = SqlInsert !(TableSettings table) !(BeamSqlBackendInsertSyntax be)
- | SqlInsertNoRows
- data SqlInsertValues be proj
- data SqlUpdate be (table :: (Type -> Type) -> Type)
- = SqlUpdate !(TableSettings table) !(BeamSqlBackendUpdateSyntax be)
- | SqlIdentityUpdate
- data SqlDelete be (table :: (Type -> Type) -> Type) = SqlDelete !(TableSettings table) !(BeamSqlBackendDeleteSyntax be)
- regrSXY_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b
- regrSYY_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b
- regrSXX_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b
- regrAvgX_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b
- regrAvgY_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b
- regrRSquared_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b
- regrCount_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b
- regrIntercept_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b
- regrSlope_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b
- corr_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b
- covarSamp_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b
- covarPop_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b
- regrSXYOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b
- regrSYYOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b
- regrSXXOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b
- regrAvgXOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b
- regrAvgYOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b
- regrRSquaredOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b
- regrCountOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b
- regrInterceptOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b
- regrSlopeOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b
- corrOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b
- covarSampOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b
- covarPopOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b
- varSamp_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QAgg be s b
- varPop_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QAgg be s b
- stddevSamp_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QAgg be s b
- stddevPop_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QAgg be s b
- varSampOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QAgg be s b
- varPopOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QAgg be s b
- stddevSampOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QAgg be s b
- stddevPopOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QAgg be s b
- (**.) :: (Floating a, BeamSqlBackend be, BeamSqlT621Backend be) => QGenExpr ctxt be s a -> QGenExpr ctxt be s a -> QGenExpr ctxt be s a
- floor_ :: (RealFrac a, Integral b, BeamSqlBackend be, BeamSqlT621Backend be) => QGenExpr ctxt be s a -> QGenExpr ctxt be s b
- ceiling_ :: (RealFrac a, Integral b, BeamSqlBackend be, BeamSqlT621Backend be) => QGenExpr ctxt be s a -> QGenExpr ctxt be s b
- sqrt_ :: (Floating a, BeamSqlBackend be, BeamSqlT621Backend be) => QGenExpr ctxt be s a -> QGenExpr ctxt be s a
- exp_ :: (Floating a, BeamSqlBackend be, BeamSqlT621Backend be) => QGenExpr ctxt be s a -> QGenExpr ctxt be s a
- ln_ :: (Floating a, BeamSqlBackend be, BeamSqlT621Backend be) => QGenExpr ctxt be s a -> QGenExpr ctxt be s a
- nthValue_ :: (BeamSqlBackend be, BeamSqlT618Backend be) => QExpr be s a -> QExpr be s Int -> QAgg be s a
- lastValue_ :: (BeamSqlBackend be, BeamSqlT616Backend be) => QExpr be s a -> QAgg be s a
- firstValue_ :: (BeamSqlBackend be, BeamSqlT616Backend be) => QExpr be s a -> QAgg be s a
- lagWithDefault_ :: (BeamSqlBackend be, BeamSqlT615Backend be) => QExpr be s a -> QExpr be s Int -> QExpr be s a -> QAgg be s a
- leadWithDefault_ :: (BeamSqlBackend be, BeamSqlT615Backend be) => QExpr be s a -> QExpr be s Int -> QExpr be s a -> QAgg be s a
- lag_ :: (BeamSqlBackend be, BeamSqlT615Backend be) => QExpr be s a -> QExpr be s Int -> QAgg be s a
- lead_ :: (BeamSqlBackend be, BeamSqlT615Backend be) => QExpr be s a -> QExpr be s Int -> QAgg be s a
- lag1_ :: (BeamSqlBackend be, BeamSqlT615Backend be) => QExpr be s a -> QAgg be s a
- lead1_ :: (BeamSqlBackend be, BeamSqlT615Backend be) => QExpr be s a -> QAgg be s a
- ntile_ :: (BeamSqlBackend be, BeamSqlT614Backend be) => QExpr be s Int -> QAgg be s a
- any_ :: BeamSql99AggregationBackend be => QExpr be s SqlBool -> QAgg be s SqlBool
- some_ :: BeamSql99AggregationBackend be => QExpr be s SqlBool -> QAgg be s SqlBool
- every_ :: BeamSql99AggregationBackend be => QExpr be s SqlBool -> QAgg be s SqlBool
- filterWhere_' :: BeamSqlT611Backend be => QAgg be s a -> QExpr be s SqlBool -> QAgg be s a
- filterWhere_ :: BeamSqlT611Backend be => QAgg be s a -> QExpr be s Bool -> QAgg be s a
- anyOver_ :: BeamSql99AggregationBackend be => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s SqlBool -> QAgg be s SqlBool
- someOver_ :: BeamSql99AggregationBackend be => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s SqlBool -> QAgg be s SqlBool
- everyOver_ :: BeamSql99AggregationBackend be => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s SqlBool -> QAgg be s SqlBool
- countOver_ :: (BeamSqlBackend be, Integral b) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QAgg be s b
- sumOver_ :: (BeamSqlBackend be, Num a) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QAgg be s (Maybe a)
- avgOver_ :: (BeamSqlBackend be, Num a) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QAgg be s (Maybe a)
- maxOver_ :: BeamSqlBackend be => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QAgg be s (Maybe a)
- minOver_ :: BeamSqlBackend be => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QAgg be s (Maybe a)
- rank_ :: BeamSqlT611Backend be => QAgg be s Int
- rowNumber_ :: BeamSql2003ExpressionBackend be => QAgg be s Int
- denseRank_ :: BeamSqlT612Backend be => QAgg be s Int
- percentRank_ :: BeamSqlT612Backend be => QAgg be s Double
- cumeDist_ :: BeamSqlT612Backend be => QAgg be s Double
- count_ :: (BeamSqlBackend be, Integral b) => QExpr be s a -> QAgg be s b
- countAll_ :: BeamSqlBackend be => QAgg be s Int
- sum_ :: (BeamSqlBackend be, Num a) => QExpr be s a -> QAgg be s (Maybe a)
- avg_ :: (BeamSqlBackend be, Num a) => QExpr be s a -> QAgg be s (Maybe a)
- max_ :: BeamSqlBackend be => QExpr be s a -> QAgg be s (Maybe a)
- min_ :: BeamSqlBackend be => QExpr be s a -> QAgg be s (Maybe a)
- allInGroupExplicitly_ :: IsSql92AggregationSetQuantifierSyntax s => Maybe s
- distinctInGroup_ :: IsSql92AggregationSetQuantifierSyntax s => Maybe s
- allInGroup_ :: IsSql92AggregationSetQuantifierSyntax s => Maybe s
- aggregate_ :: (BeamSqlBackend be, Aggregable be a, Projectible be r, Projectible be a, ContextRewritable a, ThreadRewritable (QNested s) (WithRewrittenContext a QValueContext)) => (r -> a) -> Q be db (QNested s) r -> Q be db s (WithRewrittenThread (QNested s) s (WithRewrittenContext a QValueContext))
- class QGroupable expr grouped | expr -> grouped, grouped -> expr where
- group_ :: expr -> grouped
- 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))
- 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))
- oneToMaybe_ :: (BeamSqlBackend be, Database be db, Table tbl, Table rel, HasTableEqualityNullable be (PrimaryKey tbl)) => DatabaseEntity be db (TableEntity rel) -> (rel (QExpr be s) -> PrimaryKey tbl (Nullable (QExpr be s))) -> tbl (QExpr be s) -> Q be db s (rel (Nullable (QExpr be s)))
- oneToManyOptional_ :: (BeamSqlBackend be, Database be db, Table tbl, Table rel, HasTableEqualityNullable be (PrimaryKey tbl)) => DatabaseEntity be db (TableEntity rel) -> (rel (QExpr be s) -> PrimaryKey tbl (Nullable (QExpr be s))) -> tbl (QExpr be s) -> Q be db s (rel (Nullable (QExpr be s)))
- oneToOne_ :: (Database be db, BeamSqlBackend be, HasTableEquality be (PrimaryKey tbl), Table tbl, Table rel) => DatabaseEntity be db (TableEntity rel) -> (rel (QExpr be s) -> PrimaryKey tbl (QExpr be s)) -> tbl (QExpr be s) -> Q be db s (rel (QExpr be s))
- oneToMany_ :: (Database be db, BeamSqlBackend be, HasTableEquality be (PrimaryKey tbl), Table tbl, Table rel) => DatabaseEntity be db (TableEntity rel) -> (rel (QExpr be s) -> PrimaryKey tbl (QExpr be s)) -> tbl (QExpr be s) -> Q be db s (rel (QExpr be s))
- type OneToOne be (db :: (Type -> Type) -> Type) s (one :: (Type -> Type) -> Type) (many :: (Type -> Type) -> Type) = OneToMany be db s one many
- type OneToMany be (db :: (Type -> Type) -> Type) s (one :: (Type -> Type) -> Type) (many :: (Type -> Type) -> Type) = BeamSqlBackend be -> BeamSqlBackendCanSerialize be Bool -> one (QExpr be s) -> Q be db s (many (QExpr be s))
- type OneToMaybe be (db :: (Type -> Type) -> Type) s (tbl :: (Type -> Type) -> Type) (rel :: (Type -> Type) -> Type) = OneToManyOptional be db s tbl rel
- type OneToManyOptional be (db :: (Type -> Type) -> Type) s (tbl :: (Type -> Type) -> Type) (rel :: (Type -> Type) -> Type) = BeamSqlBackend be -> BeamSqlBackendCanSerialize be Bool -> BeamSqlBackendCanSerialize be SqlNull -> tbl (QExpr be s) -> Q be db s (rel (Nullable (QExpr be s)))
- type ManyToMany be (db :: (Type -> Type) -> Type) (left :: (Type -> Type) -> Type) (right :: (Type -> Type) -> Type) = 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))
- type ManyToManyThrough be (db :: (Type -> Type) -> Type) (through :: (Type -> Type) -> Type) (left :: (Type -> Type) -> Type) (right :: (Type -> Type) -> Type) = 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))
- (<|>.) :: (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
- fromMaybe_ :: BeamSqlBackend be => QGenExpr ctxt be s a -> QGenExpr ctxt be s (Maybe a) -> QGenExpr ctxt be s a
- coalesce_ :: BeamSqlBackend be => [QGenExpr ctxt be s (Maybe a)] -> QGenExpr ctxt be s a -> QGenExpr ctxt be s a
- if_ :: BeamSqlBackend be => [QIfCond context be s a] -> QIfElse context be s a -> QGenExpr context be s a
- else_ :: QGenExpr context be s a -> QIfElse context be s a
- then_' :: QGenExpr context be s SqlBool -> QGenExpr context be s a -> QIfCond context be s a
- then_ :: QGenExpr context be s Bool -> QGenExpr context be s a -> QIfCond context be s a
- desc_ :: BeamSqlBackend be => QExpr be s a -> QOrd be s a
- asc_ :: BeamSqlBackend be => QExpr be s a -> QOrd be s a
- nullsLast_ :: IsSql2003OrderingElementaryOLAPOperationsSyntax (BeamSqlBackendOrderingSyntax be) => QOrd be s a -> QOrd be s a
- nullsFirst_ :: IsSql2003OrderingElementaryOLAPOperationsSyntax (BeamSqlBackendOrderingSyntax be) => QOrd be s a -> QOrd be s a
- orderBy_ :: (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)
- withWindow_ :: (ProjectibleWithPredicate WindowFrameContext be (WithExprContext (BeamSqlBackendWindowFrameSyntax' be)) window, Projectible be r, Projectible be a, ContextRewritable a, ThreadRewritable (QNested s) (WithRewrittenContext a QValueContext)) => (r -> window) -> (r -> window -> a) -> Q be db (QNested s) r -> Q be db s (WithRewrittenThread (QNested s) s (WithRewrittenContext a QValueContext))
- over_ :: BeamSql2003ExpressionBackend be => QAgg be s a -> QWindow be s -> QWindowExpr be s a
- frame_ :: (BeamSql2003ExpressionBackend be, SqlOrderable be ordering, Projectible be partition) => Maybe partition -> Maybe ordering -> QFrameBounds be -> QWindow be s
- orderPartitionBy_ :: partition -> Maybe partition
- partitionBy_ :: partition -> Maybe partition
- noOrder_ :: Maybe (QOrd be s Int)
- noPartition_ :: Maybe (QExpr be s Int)
- nrows_ :: BeamSql2003ExpressionBackend be => Int -> QFrameBound be
- unbounded_ :: BeamSql2003ExpressionBackend be => QFrameBound be
- bounds_ :: BeamSql2003ExpressionBackend be => QFrameBound be -> Maybe (QFrameBound be) -> QFrameBounds be
- fromBound_ :: BeamSql2003ExpressionBackend be => QFrameBound be -> QFrameBounds be
- noBounds_ :: QFrameBounds be
- default_ :: BeamSqlBackend be => QGenExpr ctxt be s a
- as_ :: QGenExpr ctxt be s a -> QGenExpr ctxt be s a
- exceptAll_ :: (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)
- except_ :: (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)
- intersectAll_ :: (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)
- intersect_ :: (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)
- unionAll_ :: (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)
- union_ :: (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)
- current_ :: BeamSqlBackend be => QField s ty -> QExpr be s ty
- trim_ :: (BeamSqlBackendIsString be text, BeamSqlBackend be) => QGenExpr context be s text -> QGenExpr context be s text
- upper_ :: (BeamSqlBackendIsString be text, BeamSqlBackend be) => QGenExpr context be s text -> QGenExpr context be s text
- lower_ :: (BeamSqlBackendIsString be text, BeamSqlBackend be) => QGenExpr context be s text -> QGenExpr context be s text
- position_ :: (BeamSqlBackendIsString be text, BeamSqlBackend be, Integral b) => QExpr be s text -> QExpr be s text -> QExpr be s b
- currentTimestamp_ :: BeamSqlBackend be => QGenExpr ctxt be s LocalTime
- bitLength_ :: BeamSqlBackend be => QGenExpr context be s SqlBitString -> QGenExpr context be s Int
- octetLength_ :: (BeamSqlBackend be, BeamSqlBackendIsString be text) => QGenExpr context be s text -> QGenExpr context be s Int
- charLength_ :: (BeamSqlBackend be, BeamSqlBackendIsString be text) => QGenExpr context be s text -> QGenExpr context be s Int
- subquery_ :: (BeamSqlBackend be, HasQBuilder be, Projectible be (QExpr be s a)) => Q be db s (QExpr be s a) -> QGenExpr ctxt be s a
- distinct_ :: (BeamSqlBackend be, BeamSql99ExpressionBackend be, HasQBuilder be, Projectible be a) => Q be db s a -> QExpr be s Bool
- unique_ :: (BeamSqlBackend be, HasQBuilder be, Projectible be a) => Q be db s a -> QExpr be s Bool
- exists_ :: (BeamSqlBackend be, HasQBuilder be, Projectible be a) => Q be db s a -> QExpr be s Bool
- offset_ :: (Projectible be a, ThreadRewritable (QNested s) a) => Integer -> Q be db (QNested s) a -> Q be db s (WithRewrittenThread (QNested s) s a)
- limit_ :: (Projectible be a, ThreadRewritable (QNested s) a) => Integer -> Q be db (QNested s) a -> Q be db s (WithRewrittenThread (QNested s) s a)
- nub_ :: (BeamSqlBackend be, Projectible be r) => Q be db s r -> Q be db s r
- 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
- relatedBy_' :: (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))
- relatedBy_ :: (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))
- related_ :: (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))
- filter_' :: BeamSqlBackend be => (r -> QExpr be s SqlBool) -> Q be db s r -> Q be db s r
- filter_ :: BeamSqlBackend be => (r -> QExpr be s Bool) -> Q be db s r -> Q be db s r
- guard_' :: BeamSqlBackend be => QExpr be s SqlBool -> Q be db s ()
- guard_ :: BeamSqlBackend be => QExpr be s Bool -> Q be db s ()
- subselect_ :: (ThreadRewritable (QNested s) r, Projectible be r) => Q be db (QNested s) r -> Q be db s (WithRewrittenThread (QNested s) s r)
- leftJoin_' :: (BeamSqlBackend be, Projectible be r, ThreadRewritable (QNested s) r, Retaggable (QExpr be s) (WithRewrittenThread (QNested s) s r)) => Q be db (QNested s) r -> (WithRewrittenThread (QNested s) s r -> QExpr be s SqlBool) -> Q be db s (Retag Nullable (WithRewrittenThread (QNested s) s r))
- leftJoin_ :: (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))
- outerJoin_' :: (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))
- outerJoin_ :: (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))
- perhaps_ :: (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))
- 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))
- 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))
- values_ :: (Projectible be a, BeamSqlBackend be) => [a] -> Q be db s a
- allFromView_ :: (Database be db, Beamable table, BeamSqlBackend be) => DatabaseEntity be db (ViewEntity table) -> Q be db s (table (QExpr be s))
- all_ :: (Database be db, BeamSqlBackend be) => DatabaseEntity be db (TableEntity table) -> Q be db s (table (QExpr be s))
- type family HaskellLiteralForQExpr x = (a :: Type)
- type SqlValableTable be (table :: (Type -> Type) -> Type) = (Beamable table, FieldsFulfillConstraint (HasSqlValueSyntax (BeamSqlBackendValueSyntax be)) table)
- class SqlValable a where
- val_ :: HaskellLiteralForQExpr a -> a
- class SqlOrderable be a | a -> be
- class SqlJustable a b | b -> a where
- data QIfCond context be s a
- data QIfElse context be s a
- class BeamSqlBackend be => SqlDeconstructMaybe be a nonNullA s | a s -> be, a -> nonNullA, a -> s, nonNullA -> s where
- reuse :: ReusableQ be db res -> Q be db s (WithRewrittenThread QAnyScope s res)
- selecting :: (BeamSql99CommonTableExpressionBackend be, HasQBuilder be, Projectible be res, ThreadRewritable QAnyScope res) => Q be db QAnyScope res -> With be db (ReusableQ be db res)
- data With be (db :: (Type -> Type) -> Type) a
- data ReusableQ be (db :: (Type -> Type) -> Type) res
- agg_ :: QAgg be s a -> QAgg be s a
- valueExpr_ :: QExpr be s a -> QExpr be s a
- class (Monoid (CustomSqlSyntax syntax), Semigroup (CustomSqlSyntax syntax), IsString (CustomSqlSyntax syntax)) => IsCustomSqlSyntax syntax where
- data CustomSqlSyntax syntax :: Type
- customExprSyntax :: CustomSqlSyntax syntax -> syntax
- renderSyntax :: syntax -> CustomSqlSyntax syntax
- class IsCustomExprFn fn res | res -> fn where
- customExpr_ :: fn -> res
- maybeType :: DataType be a -> DataType be (Maybe a)
- array :: (Typeable a, BeamSql99DataTypeBackend be) => DataType be a -> Int -> DataType be (Vector a)
- binaryLargeObject :: BeamSql99DataTypeBackend be => DataType be Text
- characterLargeObject :: BeamSql99DataTypeBackend be => DataType be Text
- boolean :: BeamSql99DataTypeBackend be => DataType be Bool
- time :: BeamSqlBackend be => Maybe Word -> DataType be TimeOfDay
- timestamp :: BeamSqlBackend be => DataType be LocalTime
- timestamptz :: BeamSqlBackend be => DataType be LocalTime
- numeric :: BeamSqlBackend be => Maybe (Word, Maybe Word) -> DataType be Scientific
- double :: BeamSqlBackend be => DataType be Double
- nationalChar :: BeamSqlBackend be => Maybe Word -> DataType be Text
- nationalVarchar :: BeamSqlBackend be => Maybe Word -> DataType be Text
- varchar :: BeamSqlBackend be => Maybe Word -> DataType be Text
- char :: BeamSqlBackend be => Maybe Word -> DataType be Text
- date :: BeamSqlBackend be => DataType be Day
- varbinary :: (BeamSqlBackend be, BeamSqlT021Backend be) => Maybe Word -> DataType be Integer
- binary :: (BeamSqlBackend be, BeamSqlT021Backend be) => Maybe Word -> DataType be Integer
- bigint :: (BeamSqlBackend be, BeamSqlT071Backend be, Integral a) => DataType be a
- smallint :: (BeamSqlBackend be, Integral a) => DataType be a
- int :: (BeamSqlBackend be, Integral a) => DataType be a
- cast_ :: BeamSqlBackend be => QGenExpr ctxt be s a -> DataType be b -> QGenExpr ctxt be s b
- newtype DataType be a = DataType (BeamSqlBackendCastTargetSyntax be)
- day_ :: (BeamSqlBackend be, HasSqlDate tgt) => ExtractField be tgt Double
- month_ :: (BeamSqlBackend be, HasSqlDate tgt) => ExtractField be tgt Double
- year_ :: (BeamSqlBackend be, HasSqlDate tgt) => ExtractField be tgt Double
- seconds_ :: (BeamSqlBackend be, HasSqlTime tgt) => ExtractField be tgt Double
- minutes_ :: (BeamSqlBackend be, HasSqlTime tgt) => ExtractField be tgt Double
- hour_ :: (BeamSqlBackend be, HasSqlTime tgt) => ExtractField be tgt Double
- extract_ :: BeamSqlBackend be => ExtractField be tgt a -> QGenExpr ctxt be s tgt -> QGenExpr cxt be s a
- newtype ExtractField be tgt a = ExtractField (Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be))
- class HasSqlTime tgt
- class HasSqlDate tgt
- in_ :: BeamSqlBackend be => QGenExpr context be s a -> [QGenExpr context be s a] -> QGenExpr context be s Bool
- between_ :: BeamSqlBackend be => QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool
- anyIn_ :: BeamSqlBackend be => [QExpr be s a] -> QQuantified be s a
- anyOf_ :: (BeamSqlBackend be, HasQBuilder be) => Q be db (QNested s) (QExpr be (QNested s) a) -> QQuantified be s a
- allIn_ :: BeamSqlBackend be => [QExpr be s a] -> QQuantified be s a
- allOf_ :: (BeamSqlBackend be, HasQBuilder be) => Q be db (QNested s) (QExpr be (QNested s) a) -> QQuantified be s a
- fromPossiblyNullBool_ :: QGenExpr context be s (Maybe Bool) -> QGenExpr context be s SqlBool
- possiblyNullBool_ :: QGenExpr context be s SqlBool -> QGenExpr context be s (Maybe Bool)
- unknownAs_ :: BeamSqlBackend be => Bool -> QGenExpr context be s SqlBool -> QGenExpr context be s Bool
- isNotUnknown_ :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s Bool
- isUnknown_ :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s Bool
- isNotFalse_ :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s Bool
- isFalse_ :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s Bool
- isNotTrue_ :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s Bool
- isTrue_ :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s Bool
- sqlBool_ :: QGenExpr context syntax s Bool -> QGenExpr context syntax s SqlBool
- data QQuantified be s r
- class SqlEq (expr :: Type -> Type) a | a -> expr where
- class SqlEq expr a => SqlEqQuantified (expr :: Type -> Type) quantified a | a -> expr quantified where
- class BeamSqlBackend be => HasSqlEqualityCheck be a where
- sqlEqE :: Proxy a -> Proxy be -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be
- sqlNeqE :: Proxy a -> Proxy be -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be
- sqlEqTriE :: Proxy a -> Proxy be -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be
- sqlNeqTriE :: Proxy a -> Proxy be -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be
- class HasSqlEqualityCheck be a => HasSqlQuantifiedEqualityCheck be a where
- sqlQEqE :: Proxy a -> Proxy be -> Maybe (BeamSqlBackendExpressionQuantifierSyntax be) -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be
- sqlQNeqE :: Proxy a -> Proxy be -> Maybe (BeamSqlBackendExpressionQuantifierSyntax be) -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be
- class SqlOrd (expr :: Type -> Type) e | e -> expr where
- class SqlOrd expr e => SqlOrdQuantified (expr :: Type -> Type) quantified e | e -> expr quantified where
- concat_ :: BeamSql99ConcatExpressionBackend be => [QGenExpr context be s Text] -> QGenExpr context be s Text
- mod_ :: (Integral a, BeamSqlBackend be) => QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s a
- div_ :: (Integral a, BeamSqlBackend be) => QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s a
- sqlNot_ :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s SqlBool
- not_ :: BeamSqlBackend be => QGenExpr context be s Bool -> QGenExpr context be s Bool
- similarTo_ :: (BeamSqlBackendIsString be text, BeamSql99ExpressionBackend be) => QGenExpr ctxt be s text -> QGenExpr ctxt be s text -> QGenExpr ctxt be s text
- like_ :: (BeamSqlBackendIsString be text, BeamSqlBackend be) => QGenExpr ctxt be s text -> QGenExpr ctxt be s text -> QGenExpr ctxt be s Bool
- (||?.) :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s SqlBool -> QGenExpr context be s SqlBool
- (&&?.) :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s SqlBool -> QGenExpr context be s SqlBool
- (||.) :: BeamSqlBackend be => QGenExpr context be s Bool -> QGenExpr context be s Bool -> QGenExpr context be s Bool
- (&&.) :: BeamSqlBackend be => QGenExpr context be s Bool -> QGenExpr context be s Bool -> QGenExpr context be s Bool
- data SqlBool
- type family QExprToIdentity x :: Type
- type family QExprToField x :: Type
- class BeamSqlBackend be => HasQBuilder be where
- buildSqlQuery :: Projectible be a => TablePrefix -> Q be db s a -> BeamSqlBackendSelectSyntax be
- data Q be (db :: (Type -> Type) -> Type) s a
- data QField s ty
- data QAssignment be s
- data QFieldAssignment be (tbl :: (Type -> Type) -> Type) a
- data QAggregateContext
- data QGroupingContext
- data QValueContext
- data QWindowingContext
- data QWindowFrameContext
- newtype QGenExpr context be s t = QExpr (TablePrefix -> BeamSqlBackendExpressionSyntax be)
- type QExpr = QGenExpr QValueContext
- data QWindow be s
- type Projectible be = ProjectibleWithPredicate AnyType be (WithExprContext (BeamSqlBackendExpressionSyntax' be))
- dbLenses :: (Generic (db (TableLens f db)), Generic (db f), GDatabaseLenses (db f) (Rep (db f)) (Rep (db (TableLens f db)))) => db (TableLens f db)
- tableLenses :: (lensType ~ Lenses t f, Generic (t lensType), Generic (t f), GTableLenses t f (Rep (t f)) (Rep (t lensType))) => t (Lenses t f)
- newtype TableLens (f :: k -> Type) (db :: (k -> Type) -> Type) (x :: k) :: forall k. (k -> Type) -> ((k -> Type) -> Type) -> k -> Type = TableLens (Lens' (db f) (f x))
- defTblFieldSettings :: (Generic (TableSettings table), GDefaultTableFieldSettings (Rep (TableSettings table) ())) => TableSettings table
- pk :: Table t => t f -> PrimaryKey t f
- fieldName :: Lens' (TableField table ty) Text
- fieldNamed :: Text -> FieldModification (TableField tbl) a
- modifyTableFields :: tbl (FieldModification (TableField tbl)) -> EntityModification (DatabaseEntity be db) be (TableEntity tbl)
- setEntityName :: IsDatabaseEntity be entity => Text -> EntityModification (DatabaseEntity be db) be entity
- modifyEntityName :: IsDatabaseEntity be entity => (Text -> Text) -> EntityModification (DatabaseEntity be db) be entity
- modifyTable :: (Beamable tbl, Table tbl) => (Text -> Text) -> tbl (FieldModification (TableField tbl)) -> EntityModification (DatabaseEntity be db) be (TableEntity tbl)
- withTableModification :: Beamable tbl => tbl (FieldModification f) -> tbl f -> tbl f
- withDbModification :: Database be db => db (entity be db) -> DatabaseModification (entity be db) be db -> db (entity be db)
- tableModification :: Beamable tbl => tbl (FieldModification f)
- dbModification :: Database be db => DatabaseModification f be db
- defaultDbSettings :: (Generic (DatabaseSettings be db), GAutoDbSettings (Rep (DatabaseSettings be db) ())) => DatabaseSettings be db
- class Database be (db :: (Type -> Type) -> Type)
- type DatabaseModification (f :: Type -> Type) be (db :: (Type -> Type) -> Type) = db (EntityModification f be)
- data EntityModification (f :: Type -> Type) be e
- data FieldModification (f :: Type -> Type) a
- data TableEntity (tbl :: (Type -> Type) -> Type)
- data DatabaseEntity be (db :: (Type -> Type) -> Type) entityType
- type DatabaseSettings be (db :: (Type -> Type) -> Type) = db (DatabaseEntity be db)
- data Lenses (t :: (Type -> Type) -> Type) (f :: Type -> Type) x
- data LensFor t x where
- type family Columnar (f :: Type -> Type) x :: Type where ...
- type C (f :: Type -> Type) a = Columnar f a
- data Columnar' (f :: Type -> Type) a
- data TableField (table :: (Type -> Type) -> Type) ty
- type TableSettings (table :: (Type -> Type) -> Type) = table (TableField table)
- type HaskellTable (table :: (Type -> Type) -> Type) = table Identity
- class (Typeable table, Beamable table, Beamable (PrimaryKey table)) => Table (table :: (Type -> Type) -> Type) where
- data PrimaryKey (table :: (Type -> Type) -> Type) (column :: Type -> Type) :: Type
- primaryKey :: table column -> PrimaryKey table column
- class Beamable (table :: (Type -> Type) -> Type)
- class (BeamBackend be, Monad m) => MonadBeam be (m :: Type -> Type) | m -> be where
- runReturningMany :: FromBackendRow be x => BeamSqlBackendSyntax be -> (m (Maybe x) -> m a) -> m a
- runNoReturn :: BeamSqlBackendSyntax be -> m ()
- runReturningOne :: FromBackendRow be x => BeamSqlBackendSyntax be -> m (Maybe x)
- runReturningList :: FromBackendRow be x => BeamSqlBackendSyntax be -> m [x]
- class BeamBackend be => FromBackendRow be a where
- fromBackendRow :: FromBackendRowM be a
- valuesNeeded :: Proxy be -> Proxy a -> Int
- data Nullable (c :: Type -> Type) x
- (<-.) :: SqlUpdatable be s lhs rhs => lhs -> rhs -> QAssignment be s
- data TxOpt
- data QueryResult a
- data ExecResult a
- runSelectReturningList :: (ReadOnlyM m, FromBackendRow Postgres a) => Sel a -> m [a]
- runSelectReturningOne :: (ReadOnlyM m, FromBackendRow Postgres a) => Sel a -> m (Maybe a)
- query :: ListContains n ReadOnlyPool xs => TxOpt -> RoPg a -> TsActionCtxT lts xs sessdata (QueryResult a)
- queryMaybe :: (ListContains n ReadOnlyPool xs, FromBackendRow Postgres a) => Sel a -> TsActionCtxT lts xs sessdata (QueryResult (Maybe a))
- queryList :: (ListContains n ReadOnlyPool xs, FromBackendRow Postgres a) => Sel a -> TsActionCtxT lts xs sessdata (QueryResult [a])
- execute :: ListContains n ReadWritePool xs => TxOpt -> Pg a -> TsActionCtxT lts xs sessdata (ExecResult a)
Documentation
The class Typeable
allows a concrete representation of a type to
be calculated.
typeRep#
Representable types of kind *
.
This class is derivable in GHC with the DeriveGeneric
flag on.
A Generic
instance must satisfy the following laws:
from
.to
≡id
to
.from
≡id
Instances
class Monad m => MonadIO (m :: Type -> Type) where #
Monads in which IO
computations may be embedded.
Any monad built by applying a sequence of monad transformers to the
IO
monad will be an instance of this class.
Instances should satisfy the following laws, which state that liftIO
is a transformer of monads:
Instances
Identity functor and monad. (a non-strict monad)
Since: base-4.8.0.0
Instances
runDelete :: (BeamSqlBackend be, MonadBeam be m) => SqlDelete be table -> m () #
:: BeamSqlBackend be | |
=> DatabaseEntity be db (TableEntity table) | Table to delete from |
-> (forall s. (forall s'. table (QExpr be s')) -> QExpr be s Bool) | Build a |
-> SqlDelete be table |
Build a SqlDelete
from a table and a way to build a WHERE
clause
runUpdate :: (BeamSqlBackend be, MonadBeam be m) => SqlUpdate be tbl -> m () #
:: (Table table, BeamSqlBackend be, SqlValableTable be (PrimaryKey table), SqlValableTable be table, HasTableEquality be (PrimaryKey table)) | |
=> DatabaseEntity be db (TableEntity table) | Table to update |
-> table Identity | Value to set to |
-> SqlUpdate be table |
Generate a SqlUpdate
that will update the given table row with the given value.
The SQL UPDATE
that is generated will set every non-primary key field for
the row where each primary key field is exactly what is given.
Note: This is a pure SQL UPDATE
command. This does not upsert or merge values.
toUpdatedValueMaybe :: (forall s. table (QExpr be s) -> Maybe (QExpr be s a)) -> QFieldAssignment be table a #
Use with set
to optionally set a fiield to a new value,
calculated based on one or more fields from the existing row
toUpdatedValue :: (forall s. table (QExpr be s) -> QExpr be s a) -> QFieldAssignment be table a #
Use with set
to set a field to a new value that is calculated
based on one or more fields from the existing row
toOldValue :: QFieldAssignment be table a #
Use with set
to not modify the field
toNewValue :: (forall s. QExpr be s a) -> QFieldAssignment be table a #
Use with set
to set a field to an explicit new value that does
not depend on any other value
setFieldsTo :: Table table => (forall s. table (QExpr be s)) -> table (QFieldAssignment be table') #
set :: Beamable table => table (QFieldAssignment be table') #
:: (BeamSqlBackend be, Table table, HasTableEquality be (PrimaryKey table), SqlValableTable be (PrimaryKey table)) | |
=> DatabaseEntity be db (TableEntity table) | The table to update |
-> table Identity | The row to update |
-> table (QFieldAssignment be table) | Updates to be made (use |
-> SqlUpdate be table |
Convenience form of updateTable
that generates a WHERE
clause
that matches only the already existing entity
:: (BeamSqlBackend be, Beamable table) | |
=> DatabaseEntity be db (TableEntity table) | The table to update |
-> table (QFieldAssignment be table) | Updates to be made (use |
-> (forall s. table (QExpr be s) -> QExpr be s Bool) | |
-> SqlUpdate be table |
A specialization of update
that is more convenient for normal tables.
:: (BeamSqlBackend be, Table table, HasTableEquality be (PrimaryKey table), SqlValableTable be (PrimaryKey table)) | |
=> DatabaseEntity be db (TableEntity table) | The table to insert into |
-> table Identity | The row to update |
-> (forall s. table (QField s) -> QAssignment be s) | A sequence of assignments to make. |
-> SqlUpdate be table |
A specialization of update
that matches the given (already existing) row
:: (BeamSqlBackend be, Beamable table) | |
=> DatabaseEntity be db (TableEntity table) | The table to insert into |
-> (forall s. table (QField s) -> QAssignment be s) | A sequence of assignments to make. |
-> (forall s. table (QExpr be s) -> QExpr be s Bool) | Build a |
-> SqlUpdate be table |
Build a SqlUpdate
given a table, a list of assignments, and a way to
build a WHERE
clause.
See the '(<-.)' operator for ways to build assignments. The argument to the
second argument is a the table parameterized over QField
, which
represents the left hand side of assignments. Sometimes, you'd like to also
get the current value of a particular column. You can use the current_
function to convert a QField
to a QGenExpr
.
insertFrom :: (BeamSqlBackend be, HasQBuilder be, Projectible be r) => Q be db QBaseScope r -> SqlInsertValues be r #
Build a SqlInsertValues
from a SqlSelect
that returns the same table
insertData :: (Projectible be r, BeamSqlBackend be) => [r] -> SqlInsertValues be r #
Build a SqlInsertValues
from arbitrarily shaped data containing expressions
insertValues :: (BeamSqlBackend be, Beamable table, FieldsFulfillConstraint (BeamSqlBackendCanSerialize be) table) => [table Identity] -> SqlInsertValues be (table (QExpr be s)) #
Build a SqlInsertValues
from concrete table values
insertExpressions :: (BeamSqlBackend be, Beamable table) => (forall s'. [table (QExpr be s')]) -> SqlInsertValues be (table (QExpr be s)) #
Build a SqlInsertValues
from series of expressions in tables
runInsert :: (BeamSqlBackend be, MonadBeam be m) => SqlInsert be table -> m () #
:: (BeamSqlBackend be, ProjectibleWithPredicate AnyType () Text (table (QField s))) | |
=> DatabaseEntity be db (TableEntity table) | Table to insert into |
-> SqlInsertValues be (table (QExpr be s)) | Values to insert. See |
-> SqlInsert be table |
Generate a SqlInsert
given a table and a source of values.
:: (BeamSqlBackend be, ProjectibleWithPredicate AnyType () Text (QExprToField r)) | |
=> DatabaseEntity be db (TableEntity table) | Table to insert into |
-> (table (QField s) -> QExprToField r) | |
-> SqlInsertValues be r | Values to insert. See |
-> SqlInsert be table |
Generate a SqlInsert
over only certain fields of a table
dumpSqlSelect :: Projectible (MockSqlBackend SqlSyntaxBuilder) res => Q (MockSqlBackend SqlSyntaxBuilder) db QBaseScope res -> IO () #
Use a special debug syntax to print out an ANSI Standard SELECT
statement
that may be generated for a given Q
.
lookup_ :: (Database be db, Table table, BeamSqlBackend be, HasQBuilder be, SqlValableTable be (PrimaryKey table), HasTableEquality be (PrimaryKey table)) => DatabaseEntity be db (TableEntity table) -> PrimaryKey table Identity -> SqlSelect be (table Identity) #
Convenience function to generate a SqlSelect
that looks up a table row
given a primary key.
selectWith :: (BeamSqlBackend be, BeamSql99CommonTableExpressionBackend be, HasQBuilder be, Projectible be res) => With be db (Q be db QBaseScope res) -> SqlSelect be (QExprToIdentity res) #
select :: (BeamSqlBackend be, HasQBuilder be, Projectible be res) => Q be db QBaseScope res -> SqlSelect be (QExprToIdentity res) #
data QBaseScope #
type QGenExprTable ctxt be s (tbl :: (Type -> Type) -> Type) = tbl (QGenExpr ctxt be s) #
A version of the table where each field is a QGenExpr
type QExprTable be s (tbl :: (Type -> Type) -> Type) = QGenExprTable QValueContext be s tbl #
Represents a select statement in the given backend, returning
rows of type a
.
data SqlInsert be (table :: (Type -> Type) -> Type) #
Represents a SQL INSERT
command that has not yet been run
SqlInsert !(TableSettings table) !(BeamSqlBackendInsertSyntax be) | |
SqlInsertNoRows |
Instances
PgReturning SqlInsert | |
Defined in Database.Beam.Postgres.Full type PgReturningType SqlInsert :: Type -> Type # returning :: (Beamable tbl, Projectible Postgres a) => SqlInsert Postgres tbl -> (tbl (QExpr Postgres PostgresInaccessible) -> a) -> PgReturningType SqlInsert (QExprToIdentity a) # | |
type PgReturningType SqlInsert | |
Defined in Database.Beam.Postgres.Full |
data SqlInsertValues be proj #
Represents a source of values that can be inserted into a table shaped like
tbl
.
data SqlUpdate be (table :: (Type -> Type) -> Type) #
Represents a SQL UPDATE
statement for the given table
.
SqlUpdate !(TableSettings table) !(BeamSqlBackendUpdateSyntax be) | |
SqlIdentityUpdate |
Instances
PgReturning SqlUpdate | |
Defined in Database.Beam.Postgres.Full type PgReturningType SqlUpdate :: Type -> Type # returning :: (Beamable tbl, Projectible Postgres a) => SqlUpdate Postgres tbl -> (tbl (QExpr Postgres PostgresInaccessible) -> a) -> PgReturningType SqlUpdate (QExprToIdentity a) # | |
type PgReturningType SqlUpdate | |
Defined in Database.Beam.Postgres.Full |
data SqlDelete be (table :: (Type -> Type) -> Type) #
Represents a SQL DELETE
statement for the given table
SqlDelete !(TableSettings table) !(BeamSqlBackendDeleteSyntax be) |
Instances
PgReturning SqlDelete | |
Defined in Database.Beam.Postgres.Full type PgReturningType SqlDelete :: Type -> Type # returning :: (Beamable tbl, Projectible Postgres a) => SqlDelete Postgres tbl -> (tbl (QExpr Postgres PostgresInaccessible) -> a) -> PgReturningType SqlDelete (QExprToIdentity a) # | |
type PgReturningType SqlDelete | |
Defined in Database.Beam.Postgres.Full |
regrSXY_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b #
regrSYY_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b #
regrSXX_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b #
regrAvgX_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b #
regrAvgY_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b #
regrRSquared_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b #
regrCount_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b #
regrIntercept_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b #
regrSlope_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b #
corr_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b #
covarSamp_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b #
covarPop_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QExpr be s a -> QExpr be s b #
regrSXYOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b #
regrSYYOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b #
regrSXXOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b #
regrAvgXOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b #
regrAvgYOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b #
regrRSquaredOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b #
regrCountOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b #
regrInterceptOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b #
regrSlopeOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b #
corrOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b #
covarSampOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b #
covarPopOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QExpr be s a -> QExpr be s b #
varSamp_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QAgg be s b #
varPop_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QAgg be s b #
stddevSamp_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QAgg be s b #
stddevPop_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => QExpr be s a -> QAgg be s b #
varSampOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QAgg be s b #
varPopOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QAgg be s b #
stddevSampOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QAgg be s b #
stddevPopOver_ :: (Num a, Floating b, BeamSqlBackend be, BeamSqlT621Backend be) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QAgg be s b #
(**.) :: (Floating a, BeamSqlBackend be, BeamSqlT621Backend be) => QGenExpr ctxt be s a -> QGenExpr ctxt be s a -> QGenExpr ctxt be s a infixr 8 #
floor_ :: (RealFrac a, Integral b, BeamSqlBackend be, BeamSqlT621Backend be) => QGenExpr ctxt be s a -> QGenExpr ctxt be s b #
ceiling_ :: (RealFrac a, Integral b, BeamSqlBackend be, BeamSqlT621Backend be) => QGenExpr ctxt be s a -> QGenExpr ctxt be s b #
sqrt_ :: (Floating a, BeamSqlBackend be, BeamSqlT621Backend be) => QGenExpr ctxt be s a -> QGenExpr ctxt be s a #
exp_ :: (Floating a, BeamSqlBackend be, BeamSqlT621Backend be) => QGenExpr ctxt be s a -> QGenExpr ctxt be s a #
ln_ :: (Floating a, BeamSqlBackend be, BeamSqlT621Backend be) => QGenExpr ctxt be s a -> QGenExpr ctxt be s a #
nthValue_ :: (BeamSqlBackend be, BeamSqlT618Backend be) => QExpr be s a -> QExpr be s Int -> QAgg be s a #
lastValue_ :: (BeamSqlBackend be, BeamSqlT616Backend be) => QExpr be s a -> QAgg be s a #
firstValue_ :: (BeamSqlBackend be, BeamSqlT616Backend be) => QExpr be s a -> QAgg be s a #
lagWithDefault_ :: (BeamSqlBackend be, BeamSqlT615Backend be) => QExpr be s a -> QExpr be s Int -> QExpr be s a -> QAgg be s a #
leadWithDefault_ :: (BeamSqlBackend be, BeamSqlT615Backend be) => QExpr be s a -> QExpr be s Int -> QExpr be s a -> QAgg be s a #
lag_ :: (BeamSqlBackend be, BeamSqlT615Backend be) => QExpr be s a -> QExpr be s Int -> QAgg be s a #
lead_ :: (BeamSqlBackend be, BeamSqlT615Backend be) => QExpr be s a -> QExpr be s Int -> QAgg be s a #
lag1_ :: (BeamSqlBackend be, BeamSqlT615Backend be) => QExpr be s a -> QAgg be s a #
lead1_ :: (BeamSqlBackend be, BeamSqlT615Backend be) => QExpr be s a -> QAgg be s a #
ntile_ :: (BeamSqlBackend be, BeamSqlT614Backend be) => QExpr be s Int -> QAgg be s a #
any_ :: BeamSql99AggregationBackend be => QExpr be s SqlBool -> QAgg be s SqlBool #
SQL99 ANY(ALL ..)
function (but without the explicit ALL)
some_ :: BeamSql99AggregationBackend be => QExpr be s SqlBool -> QAgg be s SqlBool #
SQL99 SOME(ALL ..)
function (but without the explicit ALL)
every_ :: BeamSql99AggregationBackend be => QExpr be s SqlBool -> QAgg be s SqlBool #
SQL99 EVERY(ALL ..)
function (but without the explicit ALL)
filterWhere_' :: BeamSqlT611Backend be => QAgg be s a -> QExpr be s SqlBool -> QAgg be s a #
Like filterWhere_
but accepting SqlBool
.
filterWhere_ :: BeamSqlT611Backend be => QAgg be s a -> QExpr be s Bool -> QAgg be s a #
Support for FILTER (WHERE ...) syntax for aggregates. Part of SQL2003 Elementary OLAP operations feature (T611).
See filterWhere_'
for a version that accepts SqlBool
.
anyOver_ :: BeamSql99AggregationBackend be => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s SqlBool -> QAgg be s SqlBool #
SQL EVERY
, SOME
, and ANY
aggregates. Operates over
SqlBool
only, as the result can be NULL
, even if all inputs are
known (no input rows).
someOver_ :: BeamSql99AggregationBackend be => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s SqlBool -> QAgg be s SqlBool #
SQL EVERY
, SOME
, and ANY
aggregates. Operates over
SqlBool
only, as the result can be NULL
, even if all inputs are
known (no input rows).
everyOver_ :: BeamSql99AggregationBackend be => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s SqlBool -> QAgg be s SqlBool #
SQL EVERY
, SOME
, and ANY
aggregates. Operates over
SqlBool
only, as the result can be NULL
, even if all inputs are
known (no input rows).
countOver_ :: (BeamSqlBackend be, Integral b) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QAgg be s b #
sumOver_ :: (BeamSqlBackend be, Num a) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QAgg be s (Maybe a) #
avgOver_ :: (BeamSqlBackend be, Num a) => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QAgg be s (Maybe a) #
maxOver_ :: BeamSqlBackend be => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QAgg be s (Maybe a) #
minOver_ :: BeamSqlBackend be => Maybe (BeamSqlBackendAggregationQuantifierSyntax be) -> QExpr be s a -> QAgg be s (Maybe a) #
rank_ :: BeamSqlT611Backend be => QAgg be s Int #
SQL2003 RANK
function (Requires T611 Elementary OLAP operations support)
rowNumber_ :: BeamSql2003ExpressionBackend be => QAgg be s Int #
SQL2003 ROW_NUMBER
function
denseRank_ :: BeamSqlT612Backend be => QAgg be s Int #
SQL2003 DENSE_RANK
function (Requires T612 Advanced OLAP operations support)
percentRank_ :: BeamSqlT612Backend be => QAgg be s Double #
SQL2003 PERCENT_RANK
function (Requires T612 Advanced OLAP operations support)
cumeDist_ :: BeamSqlT612Backend be => QAgg be s Double #
SQL2003 CUME_DIST
function (Requires T612 Advanced OLAP operations support)
count_ :: (BeamSqlBackend be, Integral b) => QExpr be s a -> QAgg be s b #
SQL COUNT(ALL ..)
function (but without the explicit ALL)
countAll_ :: BeamSqlBackend be => QAgg be s Int #
SQL COUNT(*)
function
sum_ :: (BeamSqlBackend be, Num a) => QExpr be s a -> QAgg be s (Maybe a) #
SQL SUM(ALL ..)
function (but without the explicit ALL)
avg_ :: (BeamSqlBackend be, Num a) => QExpr be s a -> QAgg be s (Maybe a) #
SQL AVG(ALL ..)
function (but without the explicit ALL)
max_ :: BeamSqlBackend be => QExpr be s a -> QAgg be s (Maybe a) #
SQL MAX(ALL ..)
function (but without the explicit ALL)
min_ :: BeamSqlBackend be => QExpr be s a -> QAgg be s (Maybe a) #
SQL MIN(ALL ..)
function (but without the explicit ALL)
allInGroupExplicitly_ :: IsSql92AggregationSetQuantifierSyntax s => Maybe s #
Compute an aggregate over all values in a group. Corresponds to the
AGG(ALL ..)
syntax. Note that ALL
is the default for most aggregations,
so you don't normally explicitly specify ALL
. However, if you need to,
you can use this function. To be explicit about quantification in the beam
query DSL, but not produce an explicit ALL
, use allInGroup_
.
allInGroup_
has the same semantic meaning, but does not produce an
explicit ALL
.
distinctInGroup_ :: IsSql92AggregationSetQuantifierSyntax s => Maybe s #
Compute an aggregate only over distinct values in a group. Corresponds to
the AGG(DISTINCT ..)
syntax.
allInGroup_ :: IsSql92AggregationSetQuantifierSyntax s => Maybe s #
Compute an aggregate over all values in a group. Corresponds semantically
to the AGG(ALL ..)
syntax, but doesn't produce an explicit ALL
. To
produce ALL
expicitly, see allInGroupExplicitly_
.
:: (BeamSqlBackend be, Aggregable be a, Projectible be r, Projectible be a, ContextRewritable a, ThreadRewritable (QNested s) (WithRewrittenContext a QValueContext)) | |
=> (r -> a) | Aggregate projection |
-> Q be db (QNested s) r | Query to aggregate over |
-> Q be db s (WithRewrittenThread (QNested s) s (WithRewrittenContext a QValueContext)) |
Compute an aggregate over a query.
The supplied aggregate projection should return an aggregate expression (an
expression containing an aggregate function such as count_
, sum_
,
countAll_
, etc), a grouping key (specified with the group_
function),
or a combination of tuples of the above.
Appropriate instances are provided up to 8-tuples.
Semantically, all grouping expressions in the projection will be added to a
SQL GROUP BY
clause and all aggregate expressions will be computed.
The return value will be the type of the aggregate projection, but
transformed to be in the normal value context (i.e., everything will become
QGenExpr
s).
For usage examples, see the manual.
class QGroupable expr grouped | expr -> grouped, grouped -> expr where #
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 QGenExpr
s in the
QGroupingContext
).
Instances
Beamable tbl => QGroupable (tbl (QExpr be s)) (tbl (QGroupExpr be s)) |
|
Defined in Database.Beam.Query.Aggregate group_ :: tbl (QExpr be s) -> tbl (QGroupExpr be s) # | |
Beamable tbl => QGroupable (tbl (Nullable (QExpr be s))) (tbl (Nullable (QGroupExpr be s))) |
|
Defined in Database.Beam.Query.Aggregate | |
QGroupable (QExpr be s a) (QGroupExpr be s a) |
|
Defined in Database.Beam.Query.Aggregate group_ :: QExpr be s a -> QGroupExpr be s a # |
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)) #
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 indformation.
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)) #
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 indformation.
:: (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.
:: (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.
:: (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.
:: (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.
type OneToOne be (db :: (Type -> Type) -> Type) s (one :: (Type -> Type) -> Type) (many :: (Type -> Type) -> Type) = OneToMany be db s one many #
Synonym of OneToMany
. Useful for giving more meaningful types, when the
relationship is meant to be one-to-one.
type OneToMany be (db :: (Type -> Type) -> Type) s (one :: (Type -> Type) -> Type) (many :: (Type -> Type) -> Type) = BeamSqlBackend be -> BeamSqlBackendCanSerialize be Bool -> one (QExpr be s) -> Q be db s (many (QExpr be s)) #
Convenience type to declare one-to-many relationships. See the manual section on relationships for more information
type OneToMaybe be (db :: (Type -> Type) -> Type) s (tbl :: (Type -> Type) -> Type) (rel :: (Type -> Type) -> Type) = OneToManyOptional be db s tbl rel #
Synonym of OneToManyOptional
. Useful for giving more meaningful types,
when the relationship is meant to be one-to-one.
type OneToManyOptional be (db :: (Type -> Type) -> Type) s (tbl :: (Type -> Type) -> Type) (rel :: (Type -> Type) -> Type) = BeamSqlBackend be -> BeamSqlBackendCanSerialize be Bool -> BeamSqlBackendCanSerialize be SqlNull -> tbl (QExpr be s) -> Q be db s (rel (Nullable (QExpr be s))) #
Convenience type to declare one-to-many relationships with a nullable foreign key. See the manual section on relationships for more information
type ManyToMany be (db :: (Type -> Type) -> Type) (left :: (Type -> Type) -> Type) (right :: (Type -> Type) -> Type) = 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)) #
Convenience type to declare many-to-many relationships. See the manual section on relationships for more information
type ManyToManyThrough be (db :: (Type -> Type) -> Type) (through :: (Type -> Type) -> Type) (left :: (Type -> Type) -> Type) (right :: (Type -> Type) -> Type) = 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)) #
Convenience type to declare many-to-many relationships with additional data. See the manual section on relationships for more information
(<|>.) :: (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 #
fromMaybe_ :: BeamSqlBackend be => QGenExpr ctxt be s a -> QGenExpr ctxt be s (Maybe a) -> QGenExpr ctxt be s a #
Converta a Maybe
value to a concrete value, by suppling a default
coalesce_ :: BeamSqlBackend be => [QGenExpr ctxt be s (Maybe a)] -> QGenExpr ctxt be s a -> QGenExpr ctxt be s a #
SQL COALESCE
support
if_ :: BeamSqlBackend be => [QIfCond context be s a] -> QIfElse context be s a -> QGenExpr context be s a #
desc_ :: BeamSqlBackend be => QExpr be s a -> QOrd be s a #
Produce a QOrd
corresponding to a SQL DESC
ordering
asc_ :: BeamSqlBackend be => QExpr be s a -> QOrd be s a #
Produce a QOrd
corresponding to a SQL ASC
ordering
nullsLast_ :: IsSql2003OrderingElementaryOLAPOperationsSyntax (BeamSqlBackendOrderingSyntax be) => QOrd be s a -> QOrd be s a #
nullsFirst_ :: IsSql2003OrderingElementaryOLAPOperationsSyntax (BeamSqlBackendOrderingSyntax be) => QOrd be s a -> QOrd be s a #
orderBy_ :: (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) #
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.
:: (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.
over_ :: BeamSql2003ExpressionBackend be => QAgg be s a -> QWindow be s -> QWindowExpr be s a #
Produce a window expression given an aggregate function and a window.
:: (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
orderPartitionBy_ :: partition -> Maybe partition #
partitionBy_ :: partition -> Maybe partition #
noPartition_ :: Maybe (QExpr be s Int) #
nrows_ :: BeamSql2003ExpressionBackend be => Int -> QFrameBound be #
unbounded_ :: BeamSql2003ExpressionBackend be => QFrameBound be #
bounds_ :: BeamSql2003ExpressionBackend be => QFrameBound be -> Maybe (QFrameBound be) -> QFrameBounds be #
fromBound_ :: BeamSql2003ExpressionBackend be => QFrameBound be -> QFrameBounds be #
noBounds_ :: QFrameBounds be #
default_ :: BeamSqlBackend be => QGenExpr ctxt be s a #
as_ :: QGenExpr ctxt be s a -> QGenExpr ctxt be s a #
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_ @Int countAll_) ..
exceptAll_ :: (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) #
SQL EXCEPT ALL
operator
except_ :: (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) #
SQL EXCEPT
operator
intersectAll_ :: (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) #
SQL INTERSECT ALL
operator
intersect_ :: (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) #
SQL INTERSECT
operator
unionAll_ :: (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) #
SQL UNION ALL
operator
union_ :: (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) #
SQL UNION
operator
current_ :: BeamSqlBackend be => QField s ty -> QExpr be s ty #
Extract an expression representing the current (non-UPDATEd) value of a QField
trim_ :: (BeamSqlBackendIsString be text, BeamSqlBackend be) => QGenExpr context be s text -> QGenExpr context be s text #
SQL TRIM
function
upper_ :: (BeamSqlBackendIsString be text, BeamSqlBackend be) => QGenExpr context be s text -> QGenExpr context be s text #
SQL UPPER
function
lower_ :: (BeamSqlBackendIsString be text, BeamSqlBackend be) => QGenExpr context be s text -> QGenExpr context be s text #
SQL LOWER
function
position_ :: (BeamSqlBackendIsString be text, BeamSqlBackend be, Integral b) => QExpr be s text -> QExpr be s text -> QExpr be s b #
SQL POSITION(.. IN ..)
function
currentTimestamp_ :: BeamSqlBackend be => QGenExpr ctxt be s LocalTime #
SQL CURRENT_TIMESTAMP
function
bitLength_ :: BeamSqlBackend be => QGenExpr context be s SqlBitString -> QGenExpr context be s Int #
SQL BIT_LENGTH
function
octetLength_ :: (BeamSqlBackend be, BeamSqlBackendIsString be text) => QGenExpr context be s text -> QGenExpr context be s Int #
SQL OCTET_LENGTH
function
charLength_ :: (BeamSqlBackend be, BeamSqlBackendIsString be text) => QGenExpr context be s text -> QGenExpr context be s Int #
SQL CHAR_LENGTH
function
subquery_ :: (BeamSqlBackend be, HasQBuilder be, Projectible be (QExpr be s a)) => Q be db s (QExpr be s a) -> QGenExpr ctxt be s a #
Project the (presumably) singular result of the given query as an expression
distinct_ :: (BeamSqlBackend be, BeamSql99ExpressionBackend be, HasQBuilder be, Projectible be a) => Q be db s a -> QExpr be s Bool #
Use the SQL99 DISTINCT
operator to determine if the given query produces a distinct result
unique_ :: (BeamSqlBackend be, HasQBuilder be, Projectible be a) => Q be db s a -> QExpr be s Bool #
Use the SQL UNIQUE
operator to determine if the given query produces a unique result
exists_ :: (BeamSqlBackend be, HasQBuilder be, Projectible be a) => Q be db s a -> QExpr be s Bool #
Use the SQL EXISTS
operator to determine if the given query returns any results
offset_ :: (Projectible be a, ThreadRewritable (QNested s) a) => Integer -> Q be db (QNested s) a -> Q be db s (WithRewrittenThread (QNested s) s a) #
Drop the first offset'
results.
limit_ :: (Projectible be a, ThreadRewritable (QNested s) a) => Integer -> Q be db (QNested s) a -> Q be db s (WithRewrittenThread (QNested s) s a) #
Limit the number of results returned by a query.
nub_ :: (BeamSqlBackend be, Projectible be r) => Q be db s r -> Q be db s r #
Only return distinct values from a query
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 #
Generate an appropriate boolean QGenExpr
comparing the given foreign key
to the given table. Useful for creating join conditions.
relatedBy_' :: (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)) #
Introduce all entries of the given table which for which the expression (which can depend on the queried table returns true)
relatedBy_ :: (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)) #
Introduce all entries of the given table which for which the expression (which can depend on the queried table returns true)
related_ :: (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)) #
Introduce all entries of the given table which are referenced by the given PrimaryKey
subselect_ :: (ThreadRewritable (QNested s) r, Projectible be r) => Q be db (QNested s) r -> Q be db s (WithRewrittenThread (QNested s) s r) #
leftJoin_' :: (BeamSqlBackend be, Projectible be r, ThreadRewritable (QNested s) r, Retaggable (QExpr be s) (WithRewrittenThread (QNested s) s r)) => Q be db (QNested s) r -> (WithRewrittenThread (QNested s) s r -> QExpr be s SqlBool) -> Q be db s (Retag Nullable (WithRewrittenThread (QNested s) s r)) #
leftJoin_ :: (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)) #
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_'
.
outerJoin_' :: (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)) #
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.
outerJoin_ :: (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)) #
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_'
perhaps_ :: (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)) #
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)'.
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)) #
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)) #
values_ :: (Projectible be a, BeamSqlBackend be) => [a] -> Q be db s a #
allFromView_ :: (Database be db, Beamable table, BeamSqlBackend be) => DatabaseEntity be db (ViewEntity table) -> Q be db s (table (QExpr be s)) #
Introduce all entries of a view into the Q
monad
all_ :: (Database be db, BeamSqlBackend be) => DatabaseEntity be db (TableEntity table) -> Q be db s (table (QExpr be s)) #
Introduce all entries of a table into the Q
monad
type family HaskellLiteralForQExpr x = (a :: Type) #
Instances
type HaskellLiteralForQExpr (table (QGenExpr context be s)) | |
Defined in Database.Beam.Query.Combinators | |
type HaskellLiteralForQExpr (table (Nullable f)) | |
Defined in Database.Beam.Query.Combinators type HaskellLiteralForQExpr (table (Nullable f)) = HaskellLiteralForQExpr_AddNullable (HaskellLiteralForQExpr (table f)) | |
type HaskellLiteralForQExpr (QGenExpr context be s a) | |
Defined in Database.Beam.Query.Combinators |
type SqlValableTable be (table :: (Type -> Type) -> Type) = (Beamable table, FieldsFulfillConstraint (HasSqlValueSyntax (BeamSqlBackendValueSyntax be)) table) #
class SqlValable a where #
val_ :: HaskellLiteralForQExpr a -> a #
Instances
(Beamable table, BeamSqlBackend be, FieldsFulfillConstraint (BeamSqlBackendCanSerialize be) table) => SqlValable (table (QGenExpr ctxt be s)) | |
Defined in Database.Beam.Query.Combinators val_ :: HaskellLiteralForQExpr (table (QGenExpr ctxt be s)) -> table (QGenExpr ctxt be s) # | |
(Beamable table, BeamSqlBackend be, FieldsFulfillConstraintNullable (BeamSqlBackendCanSerialize be) table) => SqlValable (table (Nullable (QGenExpr ctxt be s))) | |
Defined in Database.Beam.Query.Combinators | |
(BeamSqlBackendCanSerialize be a, BeamSqlBackend be) => SqlValable (QGenExpr ctxt be s a) | |
Defined in Database.Beam.Query.Combinators val_ :: HaskellLiteralForQExpr (QGenExpr ctxt be s a) -> QGenExpr ctxt be s a # |
class SqlOrderable be a | a -> be #
makeSQLOrdering
Instances
class SqlJustable a b | b -> a where #
Type class for things that can be nullable. This includes 'QExpr (Maybe a)', 'tbl (Nullable QExpr)', and 'PrimaryKey tbl (Nullable QExpr)'
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.
Return either a 'QExpr (Maybe x)' representing Nothing
or a nullable Table
or
PrimaryKey
filled with Nothing
.
Instances
(Table t, BeamSqlBackend be) => SqlJustable (t (QExpr be s)) (t (Nullable (QExpr be s))) | |
Table t => SqlJustable (t Identity) (t (Nullable Identity)) | |
(Table t, BeamSqlBackend be) => SqlJustable (PrimaryKey t (QExpr be s)) (PrimaryKey t (Nullable (QExpr be s))) | |
Defined in Database.Beam.Query.Combinators just_ :: PrimaryKey t (QExpr be s) -> PrimaryKey t (Nullable (QExpr be s)) # nothing_ :: PrimaryKey t (Nullable (QExpr be s)) # | |
Table t => SqlJustable (PrimaryKey t Identity) (PrimaryKey t (Nullable Identity)) | |
Defined in Database.Beam.Query.Combinators just_ :: PrimaryKey t Identity -> PrimaryKey t (Nullable Identity) # nothing_ :: PrimaryKey t (Nullable Identity) # | |
BeamSqlBackend be => SqlJustable (QExpr be s a) (QExpr be s (Maybe a)) | |
class BeamSqlBackend be => SqlDeconstructMaybe be a nonNullA s | a s -> be, a -> nonNullA, a -> s, nonNullA -> s where #
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'.
isJust_ :: a -> QGenExpr ctxt be s Bool #
Returns a QGenExpr
that evaluates to true when the first argument is not null
isNothing_ :: a -> QGenExpr ctxt be s Bool #
Returns a QGenExpr
that evaluates to true when the first argument is null
maybe_ :: QGenExpr ctxt be s y -> (nonNullA -> QGenExpr ctxt be s y) -> a -> QGenExpr ctxt be s y #
Given an object (third argument) which may or may not be null, return the default value if null (first argument), or transform the value that could be null to yield the result of the expression (second argument)
Instances
(BeamSqlBackend be, Beamable t) => SqlDeconstructMaybe be (t (Nullable (QGenExpr ctxt be s))) (t (QGenExpr ctxt be s)) s | |
Defined in Database.Beam.Query.Combinators | |
BeamSqlBackend be => SqlDeconstructMaybe be (QGenExpr ctxt be s (Maybe x)) (QGenExpr ctxt be s x) s | |
Defined in Database.Beam.Query.Combinators |
selecting :: (BeamSql99CommonTableExpressionBackend be, HasQBuilder be, Projectible be res, ThreadRewritable QAnyScope res) => Q be db QAnyScope res -> With be db (ReusableQ be db res) #
data With be (db :: (Type -> Type) -> Type) a #
Instances
Monad (With be db) | |
Functor (With be db) | |
IsSql99RecursiveCommonTableExpressionSelectSyntax (BeamSqlBackendSelectSyntax be) => MonadFix (With be db) | |
Defined in Database.Beam.Query.CTE | |
Applicative (With be db) | |
Defined in Database.Beam.Query.CTE |
agg_ :: QAgg be s a -> QAgg be s a #
Force a QGenExpr
to be typed as an aggregate. Useful for defining custom
aggregates for use in aggregate_
.
valueExpr_ :: QExpr be s a -> QExpr be s a #
class (Monoid (CustomSqlSyntax syntax), Semigroup (CustomSqlSyntax syntax), IsString (CustomSqlSyntax syntax)) => IsCustomSqlSyntax syntax where #
A type-class for expression syntaxes that can embed custom expressions.
data CustomSqlSyntax syntax :: Type #
customExprSyntax :: CustomSqlSyntax syntax -> syntax #
Given an arbitrary string-like expression, produce a syntax
that represents the
ByteString
as a SQL expression.
renderSyntax :: syntax -> CustomSqlSyntax syntax #
Given an arbitrary syntax
, produce a string-like value that corresponds to
how that syntax would look when rendered in the backend.
class IsCustomExprFn fn res | res -> fn where #
customExpr_ :: fn -> res #
Instances
BeamSqlBackendHasCustomSyntax be => IsCustomExprFn (CustomSqlSnippet be) (QGenExpr ctxt be s res) | |
Defined in Database.Beam.Query.CustomSQL customExpr_ :: CustomSqlSnippet be -> QGenExpr ctxt be s res # | |
(IsCustomExprFn a res, BeamSqlBackendHasCustomSyntax be) => IsCustomExprFn (CustomSqlSnippet be -> a) (QGenExpr ctxt be s r -> res) | |
Defined in Database.Beam.Query.CustomSQL customExpr_ :: (CustomSqlSnippet be -> a) -> QGenExpr ctxt be s r -> res # |
array :: (Typeable a, BeamSql99DataTypeBackend be) => DataType be a -> Int -> DataType be (Vector a) #
SQL99 array data types
binaryLargeObject :: BeamSql99DataTypeBackend be => DataType be Text #
SQL99 BLOB
data type
characterLargeObject :: BeamSql99DataTypeBackend be => DataType be Text #
SQL99 CLOB
data type
boolean :: BeamSql99DataTypeBackend be => DataType be Bool #
SQL99 BOOLEAN
data type
timestamp :: BeamSqlBackend be => DataType be LocalTime #
SQL92 TIMESTAMP WITHOUT TIME ZONE
data type
timestamptz :: BeamSqlBackend be => DataType be LocalTime #
SQL92 TIMESTAMP WITH TIME ZONE
data type
numeric :: BeamSqlBackend be => Maybe (Word, Maybe Word) -> DataType be Scientific #
SQL92 NUMERIC
data type
double :: BeamSqlBackend be => DataType be Double #
SQL92 DOUBLE
data type
nationalChar :: BeamSqlBackend be => Maybe Word -> DataType be Text #
SQL92 NATIONAL CHARACTER
data type
nationalVarchar :: BeamSqlBackend be => Maybe Word -> DataType be Text #
SQL92 NATIONAL CHARACTER VARYING
data type
date :: BeamSqlBackend be => DataType be Day #
SQL92 DATE
data type
varbinary :: (BeamSqlBackend be, BeamSqlT021Backend be) => Maybe Word -> DataType be Integer #
SQL2003 Optional VARBINARY
data type
binary :: (BeamSqlBackend be, BeamSqlT021Backend be) => Maybe Word -> DataType be Integer #
SQL2003 Optional BINARY
data type
bigint :: (BeamSqlBackend be, BeamSqlT071Backend be, Integral a) => DataType be a #
SQL2008 Optional BIGINT
data type
smallint :: (BeamSqlBackend be, Integral a) => DataType be a #
SQL92 SMALLINT
data type
int :: (BeamSqlBackend be, Integral a) => DataType be a #
SQL92 INTEGER
data type
cast_ :: BeamSqlBackend be => QGenExpr ctxt be s a -> DataType be b -> QGenExpr ctxt be s b #
Cast a value to a specific data type, specified using DataType
.
Note: this may fail at run-time if the cast is invalid for a particular value
A data type in a given IsSql92DataTypeSyntax
which describes a SQL type
mapping to the Haskell type a
Instances
Eq (BeamSqlBackendCastTargetSyntax be) => Eq (DataType be a) | |
Sql92DisplaySyntax (BeamSqlBackendCastTargetSyntax be) => Show (DataType be a) | |
day_ :: (BeamSqlBackend be, HasSqlDate tgt) => ExtractField be tgt Double #
month_ :: (BeamSqlBackend be, HasSqlDate tgt) => ExtractField be tgt Double #
year_ :: (BeamSqlBackend be, HasSqlDate tgt) => ExtractField be tgt Double #
seconds_ :: (BeamSqlBackend be, HasSqlTime tgt) => ExtractField be tgt Double #
Extracts the hours, minutes, or seconds from any timestamp or time field
minutes_ :: (BeamSqlBackend be, HasSqlTime tgt) => ExtractField be tgt Double #
Extracts the hours, minutes, or seconds from any timestamp or time field
hour_ :: (BeamSqlBackend be, HasSqlTime tgt) => ExtractField be tgt Double #
Extracts the hours, minutes, or seconds from any timestamp or time field
extract_ :: BeamSqlBackend be => ExtractField be tgt a -> QGenExpr ctxt be s tgt -> QGenExpr cxt be s a #
Extracts the given field from the target expression
newtype ExtractField be tgt a #
A field that can be extracted from SQL expressions of type tgt
that results in a type a
, in backend be
.
class HasSqlTime tgt #
Type-class for types that contain a time component
Instances
HasSqlTime UTCTime | |
Defined in Database.Beam.Query.Extract | |
HasSqlTime LocalTime | |
Defined in Database.Beam.Query.Extract | |
HasSqlTime TimeOfDay | |
Defined in Database.Beam.Query.Extract |
class HasSqlDate tgt #
Type-class for types that contain a date component
Instances
HasSqlDate UTCTime | |
Defined in Database.Beam.Query.Extract | |
HasSqlDate LocalTime | |
Defined in Database.Beam.Query.Extract | |
HasSqlDate Day | |
Defined in Database.Beam.Query.Extract |
in_ :: BeamSqlBackend be => QGenExpr context be s a -> [QGenExpr context be s a] -> QGenExpr context be s Bool infix 4 #
SQL IN
predicate
between_ :: BeamSqlBackend be => QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool infix 4 #
SQL BETWEEN
clause
anyIn_ :: BeamSqlBackend be => [QExpr be s a] -> QQuantified be s a #
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
anyOf_ :: (BeamSqlBackend be, HasQBuilder be) => Q be db (QNested s) (QExpr be (QNested s) a) -> QQuantified be s a #
A QQuantified
representing a SQL ANY(..)
for use with a
quantified comparison operator
Accepts a subquery. Use anyIn_
for an explicit list
allIn_ :: BeamSqlBackend be => [QExpr be s a] -> QQuantified be s a #
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
allOf_ :: (BeamSqlBackend be, HasQBuilder be) => Q be db (QNested s) (QExpr be (QNested s) a) -> QQuantified be s a #
A QQuantified
representing a SQL ALL(..)
for use with a
quantified comparison operator
Accepts a subquery. Use allIn_
for an explicit list
unknownAs_ :: BeamSqlBackend be => Bool -> QGenExpr context be s SqlBool -> QGenExpr context be s Bool #
Return the first argument if the expression has the unknown SQL value
See sqlBool_
for the inverse
isNotUnknown_ :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s Bool #
SQL IS NOT UNKNOWN
operator
isUnknown_ :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s Bool #
SQL IS UNKNOWN
operator
isNotFalse_ :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s Bool #
SQL IS NOT FALSE
operator
isFalse_ :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s Bool #
SQL IS FALSE
operator
isNotTrue_ :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s Bool #
SQL IS NOT TRUE
operator
isTrue_ :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s Bool #
SQL IS TRUE
operator
sqlBool_ :: QGenExpr context syntax s Bool -> QGenExpr context syntax s SqlBool #
Convert a known not null bool to a SqlBool
. See unknownAs_
for the inverse
data QQuantified be s r #
A data structure representing the set to quantify a comparison operator over.
Instances
(BeamSqlBackend be, HasSqlQuantifiedEqualityCheck be a) => SqlEqQuantified (QGenExpr context be s) (QQuantified be s a) (QGenExpr context be s a) | Two arbitrary expressions can be quantifiably compared for equality. |
Defined in Database.Beam.Query.Ord | |
BeamSqlBackend be => SqlOrdQuantified (QGenExpr context be s) (QQuantified be s a) (QGenExpr context be s a) | |
Defined in Database.Beam.Query.Ord (<*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool # (>*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool # (<=*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool # (>=*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool # |
class SqlEq (expr :: Type -> Type) a | a -> expr where #
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
(==.) :: a -> a -> expr Bool infix 4 #
Given two expressions, returns whether they are equal, using Haskell semantics (NULLs handled properly)
(/=.) :: a -> a -> expr Bool infix 4 #
Given two expressions, returns whether they are not equal, using Haskell semantics (NULLs handled properly)
(==?.) :: a -> a -> expr SqlBool #
Given two expressions, returns the SQL tri-state boolean when compared for equality
(/=?.) :: a -> a -> expr SqlBool #
Given two expressions, returns the SQL tri-state boolean when compared for inequality
Instances
(BeamSqlBackend be, Beamable tbl, FieldsFulfillConstraint (HasSqlEqualityCheck be) tbl) => SqlEq (QGenExpr context be s) (tbl (QGenExpr context be s)) | Compare two arbitrary |
Defined in Database.Beam.Query.Ord (==.) :: tbl (QGenExpr context be s) -> tbl (QGenExpr context be s) -> QGenExpr context be s Bool # (/=.) :: tbl (QGenExpr context be s) -> tbl (QGenExpr context be s) -> QGenExpr context be s Bool # (==?.) :: tbl (QGenExpr context be s) -> tbl (QGenExpr context be s) -> QGenExpr context be s SqlBool # (/=?.) :: tbl (QGenExpr context be s) -> tbl (QGenExpr context be s) -> QGenExpr context be s SqlBool # | |
(BeamSqlBackend be, Beamable tbl, FieldsFulfillConstraintNullable (HasSqlEqualityCheck be) tbl) => SqlEq (QGenExpr context be s) (tbl (Nullable (QGenExpr context be s))) | |
Defined in Database.Beam.Query.Ord (==.) :: tbl (Nullable (QGenExpr context be s)) -> tbl (Nullable (QGenExpr context be s)) -> QGenExpr context be s Bool # (/=.) :: tbl (Nullable (QGenExpr context be s)) -> tbl (Nullable (QGenExpr context be s)) -> QGenExpr context be s Bool # (==?.) :: tbl (Nullable (QGenExpr context be s)) -> tbl (Nullable (QGenExpr context be s)) -> QGenExpr context be s SqlBool # (/=?.) :: tbl (Nullable (QGenExpr context be s)) -> tbl (Nullable (QGenExpr context be s)) -> QGenExpr context be s SqlBool # | |
(BeamSqlBackend be, HasSqlEqualityCheck be a) => SqlEq (QGenExpr context be s) (QGenExpr context be s a) | Compare two arbitrary expressions (of the same type) for equality |
Defined in Database.Beam.Query.Ord (==.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool # (/=.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool # (==?.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s SqlBool # (/=?.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s SqlBool # |
class SqlEq expr a => SqlEqQuantified (expr :: Type -> Type) quantified a | a -> expr quantified where #
Class for expression types for which there is a notion of quantified equality.
(==*.) :: a -> quantified -> expr SqlBool infix 4 #
Quantified equality and inequality using SQL semantics (tri-state boolean)
(/=*.) :: a -> quantified -> expr SqlBool infix 4 #
Quantified equality and inequality using SQL semantics (tri-state boolean)
Instances
(BeamSqlBackend be, HasSqlQuantifiedEqualityCheck be a) => SqlEqQuantified (QGenExpr context be s) (QQuantified be s a) (QGenExpr context be s a) | Two arbitrary expressions can be quantifiably compared for equality. |
Defined in Database.Beam.Query.Ord |
class BeamSqlBackend be => HasSqlEqualityCheck be a where #
Class for Haskell types that can be compared for equality in the given backend
Nothing
sqlEqE :: Proxy a -> Proxy be -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be #
sqlNeqE :: Proxy a -> Proxy be -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be #
sqlEqTriE :: Proxy a -> Proxy be -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be #
Tri-state equality
sqlNeqTriE :: Proxy a -> Proxy be -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be #
Tri-state equality
Instances
class HasSqlEqualityCheck be a => HasSqlQuantifiedEqualityCheck be a where #
Class for Haskell types that can be compared for quantified equality in the given backend
Nothing
sqlQEqE :: Proxy a -> Proxy be -> Maybe (BeamSqlBackendExpressionQuantifierSyntax be) -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be #
sqlQNeqE :: Proxy a -> Proxy be -> Maybe (BeamSqlBackendExpressionQuantifierSyntax be) -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be -> BeamSqlBackendExpressionSyntax be #
Instances
class SqlOrd (expr :: Type -> Type) e | e -> expr where #
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.
(<.) :: e -> e -> expr Bool infix 4 #
(>.) :: e -> e -> expr Bool infix 4 #
Instances
BeamSqlBackend be => SqlOrd (QGenExpr context be s) (QGenExpr context be s a) | |
Defined in Database.Beam.Query.Ord (<.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool # (>.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool # (<=.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool # (>=.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool # |
class SqlOrd expr e => SqlOrdQuantified (expr :: Type -> Type) quantified e | e -> expr quantified where #
Class for things which can be quantifiably compared.
(<*.) :: e -> quantified -> expr Bool infix 4 #
(>*.) :: e -> quantified -> expr Bool infix 4 #
Instances
BeamSqlBackend be => SqlOrdQuantified (QGenExpr context be s) (QQuantified be s a) (QGenExpr context be s a) | |
Defined in Database.Beam.Query.Ord (<*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool # (>*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool # (<=*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool # (>=*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool # |
concat_ :: BeamSql99ConcatExpressionBackend be => [QGenExpr context be s Text] -> QGenExpr context be s Text #
SQL CONCAT
function
mod_ :: (Integral a, BeamSqlBackend be) => QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s a infixl 7 #
SQL %
operator
div_ :: (Integral a, BeamSqlBackend be) => QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s a infixl 7 #
SQL /
operator
sqlNot_ :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s SqlBool #
SQL NOT
operator, but operating on SqlBool
instead
not_ :: BeamSqlBackend be => QGenExpr context be s Bool -> QGenExpr context be s Bool #
SQL NOT
operator
similarTo_ :: (BeamSqlBackendIsString be text, BeamSql99ExpressionBackend be) => QGenExpr ctxt be s text -> QGenExpr ctxt be s text -> QGenExpr ctxt be s text infix 4 #
SQL99 SIMILAR TO
operator
like_ :: (BeamSqlBackendIsString be text, BeamSqlBackend be) => QGenExpr ctxt be s text -> QGenExpr ctxt be s text -> QGenExpr ctxt be s Bool infix 4 #
SQL LIKE
operator
(||?.) :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s SqlBool -> QGenExpr context be s SqlBool infixr 2 #
SQL OR
operator
(&&?.) :: BeamSqlBackend be => QGenExpr context be s SqlBool -> QGenExpr context be s SqlBool -> QGenExpr context be s SqlBool infixr 3 #
SQL AND
operator for SqlBool
(||.) :: BeamSqlBackend be => QGenExpr context be s Bool -> QGenExpr context be s Bool -> QGenExpr context be s Bool infixr 2 #
SQL OR
operator
(&&.) :: BeamSqlBackend be => QGenExpr context be s Bool -> QGenExpr context be s Bool -> QGenExpr context be s Bool infixr 3 #
SQL AND
operator
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.
type family QExprToIdentity x :: Type #
Instances
type family QExprToField x :: Type #
Instances
class BeamSqlBackend be => HasQBuilder be where #
buildSqlQuery :: Projectible be a => TablePrefix -> Q be db s a -> BeamSqlBackendSelectSyntax be #
Instances
HasQBuilder Postgres | |
Defined in Database.Beam.Postgres.Types buildSqlQuery :: Projectible Postgres a => TablePrefix -> Q Postgres db s a -> BeamSqlBackendSelectSyntax Postgres # | |
BeamSqlBackend (MockSqlBackend cmd) => HasQBuilder (MockSqlBackend cmd) | |
Defined in Database.Beam.Query.Types buildSqlQuery :: Projectible (MockSqlBackend cmd) a => TablePrefix -> Q (MockSqlBackend cmd) db s a -> BeamSqlBackendSelectSyntax (MockSqlBackend cmd) # |
data Q be (db :: (Type -> Type) -> Type) s a #
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
QGenExpr
s. syntax
represents the SQL syntax that this query is building.
Instances
Beamable t => ProjectibleWithPredicate AnyType () Text (t (QField s)) | |
Defined in Database.Beam.Query.Internal project' :: Monad m => Proxy AnyType -> Proxy ((), Text) -> (forall context. AnyType context => Proxy context -> Proxy () -> Text -> m Text) -> t (QField s) -> m (t (QField s)) # projectSkeleton' :: Monad m => Proxy AnyType -> Proxy ((), Text) -> (forall context. AnyType context => Proxy context -> Proxy () -> m Text) -> m (t (QField s)) # | |
Beamable t => ProjectibleWithPredicate AnyType () Text (t (Nullable (QField s))) | |
Defined in Database.Beam.Query.Internal 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))) # projectSkeleton' :: Monad m => Proxy AnyType -> Proxy ((), Text) -> (forall context. AnyType context => Proxy context -> Proxy () -> m Text) -> m (t (Nullable (QField s))) # | |
ProjectibleWithPredicate AnyType () Text (QField s a) | |
Defined in Database.Beam.Query.Internal project' :: Monad m => Proxy AnyType -> Proxy ((), Text) -> (forall context. AnyType context => Proxy context -> Proxy () -> Text -> m Text) -> QField s a -> m (QField s a) # projectSkeleton' :: Monad m => Proxy AnyType -> Proxy ((), Text) -> (forall context. AnyType context => Proxy context -> Proxy () -> m Text) -> m (QField s a) # | |
(BeamSqlBackend be, Beamable tbl) => SqlUpdatable be s (tbl (QField s)) (tbl (QExpr be s)) | |
Defined in Database.Beam.Query.Combinators (<-.) :: tbl (QField s) -> tbl (QExpr be s) -> QAssignment be s # | |
(BeamSqlBackend be, Beamable tbl) => SqlUpdatable be s (tbl (Nullable (QField s))) (tbl (Nullable (QExpr be s))) | |
Defined in Database.Beam.Query.Combinators | |
BeamSqlBackend be => SqlUpdatable be s (QField s a) (QExpr be s a) | |
Defined in Database.Beam.Query.Combinators (<-.) :: QField s a -> QExpr be s a -> QAssignment be s # | |
Eq (QField s ty) | |
Ord (QField s ty) | |
Defined in Database.Beam.Query.Internal | |
Show (QField s ty) | |
data QAssignment be s #
Instances
Semigroup (QAssignment be s) | |
Defined in Database.Beam.Query.Internal (<>) :: QAssignment be s -> QAssignment be s -> QAssignment be s # sconcat :: NonEmpty (QAssignment be s) -> QAssignment be s # stimes :: Integral b => b -> QAssignment be s -> QAssignment be s # | |
Monoid (QAssignment be s) | |
Defined in Database.Beam.Query.Internal mempty :: QAssignment be s # mappend :: QAssignment be s -> QAssignment be s -> QAssignment be s # mconcat :: [QAssignment be s] -> QAssignment be s # |
data QFieldAssignment be (tbl :: (Type -> Type) -> Type) a #
data QAggregateContext #
Instances
PgIsArrayContext QAggregateContext | |
Defined in Database.Beam.Postgres.PgSpecific mkArraySyntax :: Proxy QAggregateContext -> PgSyntax -> PgSyntax | |
type ContextName QAggregateContext | |
Defined in Database.Beam.Query.Internal |
data QGroupingContext #
Instances
Beamable tbl => QGroupable (tbl (QExpr be s)) (tbl (QGroupExpr be s)) |
|
Defined in Database.Beam.Query.Aggregate group_ :: tbl (QExpr be s) -> tbl (QGroupExpr be s) # | |
Beamable tbl => QGroupable (tbl (Nullable (QExpr be s))) (tbl (Nullable (QGroupExpr be s))) |
|
Defined in Database.Beam.Query.Aggregate | |
QGroupable (QExpr be s a) (QGroupExpr be s a) |
|
Defined in Database.Beam.Query.Aggregate group_ :: QExpr be s a -> QGroupExpr be s a # | |
type ContextName QGroupingContext | |
Defined in Database.Beam.Query.Internal |
data QValueContext #
Instances
(BeamSqlBackend be, Beamable tbl) => SqlUpdatable be s (tbl (QField s)) (tbl (QExpr be s)) | |
Defined in Database.Beam.Query.Combinators (<-.) :: tbl (QField s) -> tbl (QExpr be s) -> QAssignment be s # | |
(BeamSqlBackend be, Beamable tbl) => SqlUpdatable be s (tbl (Nullable (QField s))) (tbl (Nullable (QExpr be s))) | |
Defined in Database.Beam.Query.Combinators | |
BeamSqlBackend be => SqlUpdatable be s (QField s a) (QExpr be s a) | |
Defined in Database.Beam.Query.Combinators (<-.) :: QField s a -> QExpr be s a -> QAssignment be s # | |
PgIsArrayContext QValueContext | |
Defined in Database.Beam.Postgres.PgSpecific mkArraySyntax :: Proxy QValueContext -> PgSyntax -> PgSyntax | |
Beamable tbl => QGroupable (tbl (QExpr be s)) (tbl (QGroupExpr be s)) |
|
Defined in Database.Beam.Query.Aggregate group_ :: tbl (QExpr be s) -> tbl (QGroupExpr be s) # | |
Beamable tbl => QGroupable (tbl (Nullable (QExpr be s))) (tbl (Nullable (QGroupExpr be s))) |
|
Defined in Database.Beam.Query.Aggregate | |
(Table t, BeamSqlBackend be) => SqlJustable (t (QExpr be s)) (t (Nullable (QExpr be s))) | |
(Table t, BeamSqlBackend be) => SqlJustable (PrimaryKey t (QExpr be s)) (PrimaryKey t (Nullable (QExpr be s))) | |
Defined in Database.Beam.Query.Combinators just_ :: PrimaryKey t (QExpr be s) -> PrimaryKey t (Nullable (QExpr be s)) # nothing_ :: PrimaryKey t (Nullable (QExpr be s)) # | |
QGroupable (QExpr be s a) (QGroupExpr be s a) |
|
Defined in Database.Beam.Query.Aggregate group_ :: QExpr be s a -> QGroupExpr be s a # | |
BeamSqlBackend be => SqlJustable (QExpr be s a) (QExpr be s (Maybe a)) | |
type ContextName QValueContext | |
Defined in Database.Beam.Query.Internal |
data QWindowingContext #
Instances
PgIsArrayContext QWindowingContext | |
Defined in Database.Beam.Postgres.PgSpecific mkArraySyntax :: Proxy QWindowingContext -> PgSyntax -> PgSyntax | |
type ContextName QWindowingContext | |
Defined in Database.Beam.Query.Internal |
data QWindowFrameContext #
Instances
type ContextName QWindowFrameContext | |
Defined in Database.Beam.Query.Internal |
newtype QGenExpr context be s t #
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 QGenExpr
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
(Beamable t, contextPredicate context) => ProjectibleWithPredicate contextPredicate be (WithExprContext (BeamSqlBackendExpressionSyntax' be)) (t (QGenExpr context be s)) | |
Defined in Database.Beam.Query.Internal 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)) # 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)) # | |
(Beamable t, contextPredicate context) => ProjectibleWithPredicate contextPredicate be (WithExprContext (BeamSqlBackendExpressionSyntax' be)) (t (Nullable (QGenExpr context be s))) | |
Defined in Database.Beam.Query.Internal 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))) # 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))) # | |
(BeamSqlBackend be, Beamable tbl) => SqlUpdatable be s (tbl (QField s)) (tbl (QExpr be s)) | |
Defined in Database.Beam.Query.Combinators (<-.) :: tbl (QField s) -> tbl (QExpr be s) -> QAssignment be s # | |
(BeamSqlBackend be, Beamable tbl) => SqlUpdatable be s (tbl (Nullable (QField s))) (tbl (Nullable (QExpr be s))) | |
Defined in Database.Beam.Query.Combinators | |
contextPredicate context => ProjectibleWithPredicate contextPredicate be (WithExprContext (BeamSqlBackendExpressionSyntax' be)) (QGenExpr context be s a) | |
Defined in Database.Beam.Query.Internal 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) # 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) # | |
BeamSqlBackend be => SqlUpdatable be s (QField s a) (QExpr be s a) | |
Defined in Database.Beam.Query.Combinators (<-.) :: QField s a -> QExpr be s a -> QAssignment be s # | |
Beamable tbl => ThreadRewritable s (tbl (QGenExpr ctxt syntax s)) | |
Defined in Database.Beam.Query.Internal type WithRewrittenThread s s' (tbl (QGenExpr ctxt syntax s)) :: Type # rewriteThread :: Proxy s' -> tbl (QGenExpr ctxt syntax s) -> WithRewrittenThread s s' (tbl (QGenExpr ctxt syntax s)) # | |
Beamable tbl => ThreadRewritable s (tbl (Nullable (QGenExpr ctxt syntax s))) | |
Defined in Database.Beam.Query.Internal type WithRewrittenThread s s' (tbl (Nullable (QGenExpr ctxt syntax s))) :: Type # rewriteThread :: Proxy s' -> tbl (Nullable (QGenExpr ctxt syntax s)) -> WithRewrittenThread s s' (tbl (Nullable (QGenExpr ctxt syntax s))) # | |
(BeamSqlBackend be, Beamable t) => SqlDeconstructMaybe be (t (Nullable (QGenExpr ctxt be s))) (t (QGenExpr ctxt be s)) s | |
Defined in Database.Beam.Query.Combinators | |
ThreadRewritable s (QGenExpr ctxt syntax s a) | |
Defined in Database.Beam.Query.Internal type WithRewrittenThread s s' (QGenExpr ctxt syntax s a) :: Type # rewriteThread :: Proxy s' -> QGenExpr ctxt syntax s a -> WithRewrittenThread s s' (QGenExpr ctxt syntax s a) # | |
BeamSqlBackend be => SqlDeconstructMaybe be (QGenExpr ctxt be s (Maybe x)) (QGenExpr ctxt be s x) s | |
Defined in Database.Beam.Query.Combinators | |
(Beamable table, BeamSqlBackend be, FieldsFulfillConstraint (BeamSqlBackendCanSerialize be) table) => SqlValable (table (QGenExpr ctxt be s)) | |
Defined in Database.Beam.Query.Combinators val_ :: HaskellLiteralForQExpr (table (QGenExpr ctxt be s)) -> table (QGenExpr ctxt be s) # | |
(Beamable table, BeamSqlBackend be, FieldsFulfillConstraintNullable (BeamSqlBackendCanSerialize be) table) => SqlValable (table (Nullable (QGenExpr ctxt be s))) | |
Defined in Database.Beam.Query.Combinators | |
Beamable tbl => ContextRewritable (tbl (QGenExpr old syntax s)) | |
Defined in Database.Beam.Query.Internal type WithRewrittenContext (tbl (QGenExpr old syntax s)) ctxt :: Type # rewriteContext :: Proxy ctxt -> tbl (QGenExpr old syntax s) -> WithRewrittenContext (tbl (QGenExpr old syntax s)) ctxt # | |
Beamable tbl => ContextRewritable (tbl (Nullable (QGenExpr old syntax s))) | |
Defined in Database.Beam.Query.Internal type WithRewrittenContext (tbl (Nullable (QGenExpr old syntax s))) ctxt :: Type # rewriteContext :: Proxy ctxt -> tbl (Nullable (QGenExpr old syntax s)) -> WithRewrittenContext (tbl (Nullable (QGenExpr old syntax s))) ctxt # | |
Beamable tbl => QGroupable (tbl (QExpr be s)) (tbl (QGroupExpr be s)) |
|
Defined in Database.Beam.Query.Aggregate group_ :: tbl (QExpr be s) -> tbl (QGroupExpr be s) # | |
Beamable tbl => QGroupable (tbl (Nullable (QExpr be s))) (tbl (Nullable (QGroupExpr be s))) |
|
Defined in Database.Beam.Query.Aggregate | |
(Table t, BeamSqlBackend be) => SqlJustable (t (QExpr be s)) (t (Nullable (QExpr be s))) | |
BeamSqlBackendHasCustomSyntax be => IsCustomExprFn (CustomSqlSnippet be) (QGenExpr ctxt be s res) | |
Defined in Database.Beam.Query.CustomSQL customExpr_ :: CustomSqlSnippet be -> QGenExpr ctxt be s res # | |
(Table t, BeamSqlBackend be) => SqlJustable (PrimaryKey t (QExpr be s)) (PrimaryKey t (Nullable (QExpr be s))) | |
Defined in Database.Beam.Query.Combinators just_ :: PrimaryKey t (QExpr be s) -> PrimaryKey t (Nullable (QExpr be s)) # nothing_ :: PrimaryKey t (Nullable (QExpr be s)) # | |
(IsCustomExprFn a res, BeamSqlBackendHasCustomSyntax be) => IsCustomExprFn (CustomSqlSnippet be -> a) (QGenExpr ctxt be s r -> res) | |
Defined in Database.Beam.Query.CustomSQL customExpr_ :: (CustomSqlSnippet be -> a) -> QGenExpr ctxt be s r -> res # | |
(BeamSqlBackend be, Beamable tbl, FieldsFulfillConstraint (HasSqlEqualityCheck be) tbl) => SqlEq (QGenExpr context be s) (tbl (QGenExpr context be s)) | Compare two arbitrary |
Defined in Database.Beam.Query.Ord (==.) :: tbl (QGenExpr context be s) -> tbl (QGenExpr context be s) -> QGenExpr context be s Bool # (/=.) :: tbl (QGenExpr context be s) -> tbl (QGenExpr context be s) -> QGenExpr context be s Bool # (==?.) :: tbl (QGenExpr context be s) -> tbl (QGenExpr context be s) -> QGenExpr context be s SqlBool # (/=?.) :: tbl (QGenExpr context be s) -> tbl (QGenExpr context be s) -> QGenExpr context be s SqlBool # | |
(BeamSqlBackend be, Beamable tbl, FieldsFulfillConstraintNullable (HasSqlEqualityCheck be) tbl) => SqlEq (QGenExpr context be s) (tbl (Nullable (QGenExpr context be s))) | |
Defined in Database.Beam.Query.Ord (==.) :: tbl (Nullable (QGenExpr context be s)) -> tbl (Nullable (QGenExpr context be s)) -> QGenExpr context be s Bool # (/=.) :: tbl (Nullable (QGenExpr context be s)) -> tbl (Nullable (QGenExpr context be s)) -> QGenExpr context be s Bool # (==?.) :: tbl (Nullable (QGenExpr context be s)) -> tbl (Nullable (QGenExpr context be s)) -> QGenExpr context be s SqlBool # (/=?.) :: tbl (Nullable (QGenExpr context be s)) -> tbl (Nullable (QGenExpr context be s)) -> QGenExpr context be s SqlBool # | |
QGroupable (QExpr be s a) (QGroupExpr be s a) |
|
Defined in Database.Beam.Query.Aggregate group_ :: QExpr be s a -> QGroupExpr be s a # | |
BeamSqlBackend be => SqlJustable (QExpr be s a) (QExpr be s (Maybe a)) | |
(BeamSqlBackend be, HasSqlQuantifiedEqualityCheck be a) => SqlEqQuantified (QGenExpr context be s) (QQuantified be s a) (QGenExpr context be s a) | Two arbitrary expressions can be quantifiably compared for equality. |
Defined in Database.Beam.Query.Ord | |
BeamSqlBackend be => SqlOrdQuantified (QGenExpr context be s) (QQuantified be s a) (QGenExpr context be s a) | |
Defined in Database.Beam.Query.Ord (<*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool # (>*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool # (<=*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool # (>=*.) :: QGenExpr context be s a -> QQuantified be s a -> QGenExpr context be s Bool # | |
(BeamSqlBackend be, HasSqlEqualityCheck be a) => SqlEq (QGenExpr context be s) (QGenExpr context be s a) | Compare two arbitrary expressions (of the same type) for equality |
Defined in Database.Beam.Query.Ord (==.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool # (/=.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool # (==?.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s SqlBool # (/=?.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s SqlBool # | |
BeamSqlBackend be => SqlOrd (QGenExpr context be s) (QGenExpr context be s a) | |
Defined in Database.Beam.Query.Ord (<.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool # (>.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool # (<=.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool # (>=.) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s Bool # | |
Retaggable (QGenExpr ctxt expr s) (QGenExpr ctxt expr s t) | |
BeamSqlBackend be => Eq (QGenExpr context be s t) | |
(Fractional a, BeamSqlBackend be, BeamSqlBackendCanSerialize be a) => Fractional (QGenExpr context be s a) | |
(Num a, BeamSqlBackend be, BeamSqlBackendCanSerialize be a) => Num (QGenExpr context be s a) | |
Defined in Database.Beam.Query.Internal (+) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s a # (-) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s a # (*) :: QGenExpr context be s a -> QGenExpr context be s a -> QGenExpr context be s a # negate :: QGenExpr context be s a -> QGenExpr context be s a # abs :: QGenExpr context be s a -> QGenExpr context be s a # signum :: QGenExpr context be s a -> QGenExpr context be s a # fromInteger :: Integer -> QGenExpr context be s a # | |
(BeamSqlBackend backend, BeamSqlBackendCanSerialize backend [Char]) => IsString (QGenExpr context backend s Text) | |
Defined in Database.Beam.Query.Internal fromString :: String -> QGenExpr context backend s Text # | |
(BeamSqlBackendCanSerialize be a, BeamSqlBackend be) => SqlValable (QGenExpr ctxt be s a) | |
Defined in Database.Beam.Query.Combinators val_ :: HaskellLiteralForQExpr (QGenExpr ctxt be s a) -> QGenExpr ctxt be s a # | |
ContextRewritable (QGenExpr old syntax s a) | |
Defined in Database.Beam.Query.Internal type WithRewrittenContext (QGenExpr old syntax s a) ctxt :: Type # rewriteContext :: Proxy ctxt -> QGenExpr old syntax s a -> WithRewrittenContext (QGenExpr old syntax s a) ctxt # | |
type WithRewrittenThread s s' (tbl (Nullable (QGenExpr ctxt syntax s))) | |
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)) | |
Defined in Database.Beam.Query.Internal | |
type WithRewrittenThread s s' (QGenExpr ctxt syntax s a) | |
Defined in Database.Beam.Query.Internal | |
type Retag tag (QGenExpr ctxt expr s t) | |
Defined in Database.Beam.Query.Internal | |
type HaskellLiteralForQExpr (table (QGenExpr context be s)) | |
Defined in Database.Beam.Query.Combinators | |
type QExprToIdentity (table (QGenExpr context syntax s)) | |
Defined in Database.Beam.Query.Types | |
type QExprToField (table (Nullable (QGenExpr context syntax s))) | |
Defined in Database.Beam.Query.Types | |
type QExprToField (table (QGenExpr context syntax s)) | |
Defined in Database.Beam.Query.Types | |
type WithRewrittenContext (tbl (Nullable (QGenExpr old syntax s))) ctxt | |
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 | |
Defined in Database.Beam.Query.Internal | |
type HaskellLiteralForQExpr (QGenExpr context be s a) | |
Defined in Database.Beam.Query.Combinators | |
type QExprToIdentity (QGenExpr context syntax s a) | |
Defined in Database.Beam.Query.Types | |
type QExprToField (QGenExpr ctxt syntax s a) | |
Defined in Database.Beam.Query.Types | |
type WithRewrittenContext (QGenExpr old syntax s a) ctxt | |
Defined in Database.Beam.Query.Internal |
type QExpr = QGenExpr QValueContext #
QGenExpr
s represent expressions not containing aggregates.
Instances
contextPredicate QWindowFrameContext => ProjectibleWithPredicate contextPredicate be (WithExprContext (BeamSqlBackendWindowFrameSyntax' be)) (QWindow be s) | |
Defined in Database.Beam.Query.Internal project' :: Monad m => Proxy contextPredicate -> Proxy (be, WithExprContext (BeamSqlBackendWindowFrameSyntax' be)) -> (forall context. contextPredicate context => Proxy context -> Proxy be -> WithExprContext (BeamSqlBackendWindowFrameSyntax' be) -> m (WithExprContext (BeamSqlBackendWindowFrameSyntax' be))) -> QWindow be s -> m (QWindow be s) # projectSkeleton' :: Monad m => Proxy contextPredicate -> Proxy (be, WithExprContext (BeamSqlBackendWindowFrameSyntax' be)) -> (forall context. contextPredicate context => Proxy context -> Proxy be -> m (WithExprContext (BeamSqlBackendWindowFrameSyntax' be))) -> m (QWindow be s) # |
type Projectible be = ProjectibleWithPredicate AnyType be (WithExprContext (BeamSqlBackendExpressionSyntax' be)) #
dbLenses :: (Generic (db (TableLens f db)), Generic (db f), GDatabaseLenses (db f) (Rep (db f)) (Rep (db (TableLens f db)))) => db (TableLens f db) #
Like tableLenses
but for types that are instances of Database
. Instead
of pattern matching on LensFor
, pattern match on TableLens
.
tableLenses :: (lensType ~ Lenses t f, Generic (t lensType), Generic (t f), GTableLenses t f (Rep (t f)) (Rep (t lensType))) => t (Lenses t f) #
Automatically deduce lenses for a table over any column tag. lenses at
global level by doing a top-level pattern match on tableLenses
, replacing
every column in the pattern with `LensFor nameOfLensForField'. The lenses
are generated per-column, not per field in the record. Thus if you have
nested Beamable
types, lenses are generated for each nested field.
For example,
data AuthorT f = AuthorT { _authorEmail :: Columnar f Text , _authorFirstName :: Columnar f Text , _authorLastName :: Columnar f Text } deriving Generic data BlogPostT f = BlogPost { _blogPostSlug :: Columnar f Text , _blogPostBody :: Columnar f Text , _blogPostDate :: Columnar f UTCTime , _blogPostAuthor :: PrimaryKey AuthorT f , _blogPostTagline :: Columnar f (Maybe Text) } deriving Generic instance Table BlogPostT where data PrimaryKey BlogPostT f = BlogPostId (Columnar f Text) primaryKey = BlogPostId . _blogPostSlug instance Table AuthorT where data PrimaryKey AuthorT f = AuthorId (Columnar f Text) primaryKey = AuthorId . _authorEmail
BlogPost (LensFor blogPostSlug (LensFor blogPostBody) (LensFor blogPostDate) (AuthorId (LensFor blogPostAuthorEmail)) (LensFor blogPostTagLine) = tableLenses
Note: In order to have GHC deduce the right type, you will need to turn off
the monomorphism restriction. This is a part of the Haskell standard that
specifies that top-level definitions must be inferred to have a monomorphic
type. However, lenses need a polymorphic type to work properly. You can
turn off the monomorphism restriction by enabling the
NoMonomorphismRestriction
extension. You can do this per-file by using
the {--} pragma at the top of the
file. You can also pass the -XNoMonomorphismRestriction
command line flag
to GHC during compilation.
newtype TableLens (f :: k -> Type) (db :: (k -> Type) -> Type) (x :: k) :: forall k. (k -> Type) -> ((k -> Type) -> Type) -> k -> Type #
defTblFieldSettings :: (Generic (TableSettings table), GDefaultTableFieldSettings (Rep (TableSettings table) ())) => TableSettings table #
Return a TableSettings
for the appropriate table
type where each column
has been given its default name. See the
manual for
information on the default naming convention.
pk :: Table t => t f -> PrimaryKey t f #
Synonym for primaryKey
fieldName :: Lens' (TableField table ty) Text #
Van Laarhoven lens to retrieve or set the field name from a TableField
.
fieldNamed :: Text -> FieldModification (TableField tbl) a #
A field modification to rename the field. Also offered under the IsString
instance for 'FieldModification (TableField tbl) a' for convenience.
modifyTableFields :: tbl (FieldModification (TableField tbl)) -> EntityModification (DatabaseEntity be db) be (TableEntity tbl) #
Construct an EntityModification
to rename the fields of a TableEntity
setEntityName :: IsDatabaseEntity be entity => Text -> EntityModification (DatabaseEntity be db) be entity #
Change the entity name without consulting the beam-assigned one
modifyEntityName :: IsDatabaseEntity be entity => (Text -> Text) -> EntityModification (DatabaseEntity be db) be entity #
Construct an EntityModification
to rename any database entity
modifyTable :: (Beamable tbl, Table tbl) => (Text -> Text) -> tbl (FieldModification (TableField tbl)) -> EntityModification (DatabaseEntity be db) be (TableEntity tbl) #
Provide an EntityModification
for TableEntity
s. Allows you to modify
the name of the table and provide a modification for each field in the
table. See the examples for withDbModification
for more.
withTableModification :: Beamable tbl => tbl (FieldModification f) -> tbl f -> tbl f #
Modify a table according to the given field modifications. Invoked by
modifyTable
to apply the modification in the database. Not used as often in
user code, but provided for completeness.
withDbModification :: Database be db => db (entity be db) -> DatabaseModification (entity be db) be db -> db (entity be db) #
Modify a database according to a given modification. Most useful for
DatabaseSettings
to change the name mappings of tables and fields. For
example, you can use this to modify the default names of a table
db :: DatabaseSettings MyDb db = defaultDbSettings `withDbModification` dbModification { -- Change default name "table1" to "Table_1". Change the name of "table1Field1" to "first_name" table1 = modifyTable (\_ -> "Table_1") (tableModification { table1Field1 = "first_name" } }
tableModification :: Beamable tbl => tbl (FieldModification f) #
Return a table modification (for use with modifyTable
) that does nothing.
Useful if you only want to change the table name, or if you only want to
modify a few fields.
For example,
tableModification { field1 = "Column1" }
is a table modification (where 'f ~ TableField tbl') that changes the
column name of field1
to Column1.
dbModification :: Database be db => DatabaseModification f be db #
Return a DatabaseModification
that does nothing. This is useful if you
only want to rename one table. You can do
dbModification { tbl1 = modifyTable (\oldNm -> "NewTableName") tableModification }
defaultDbSettings :: (Generic (DatabaseSettings be db), GAutoDbSettings (Rep (DatabaseSettings be db) ())) => DatabaseSettings be db #
Automatically provide names for tables, and descriptions for tables (using
defTblFieldSettings
). Your database must implement Generic
, and must be
auto-derivable. For more information on name generation, see the
manual
class Database be (db :: (Type -> Type) -> Type) #
Allows introspection into database types.
All database types must be of kind '(* -> *) -> *'. If the type parameter
is named f
, each field must be of the type of f
applied to some type
for which an IsDatabaseEntity
instance exists.
The be
type parameter is necessary so that the compiler can
ensure that backend-specific entities only work on the proper
backend.
Entities are documented under the corresponding section and in the manual
Instances
Database be Db Source # | |
Defined in TsWeb.Tables.Session.Test zipTables :: Monad m => Proxy be -> (forall tbl. (IsDatabaseEntity be tbl, DatabaseEntityRegularRequirements be tbl) => f tbl -> g tbl -> m (h tbl)) -> Db f -> Db g -> m (Db h) # |
type DatabaseModification (f :: Type -> Type) be (db :: (Type -> Type) -> Type) = db (EntityModification f be) #
A helper data type that lets you modify a database schema. Converts all entities in the database into functions from that entity to itself.
data EntityModification (f :: Type -> Type) be e #
A newtype wrapper around 'f e -> f e' (i.e., an endomorphism between entity
types in f
). You usually want to use modifyTable
or another function to
contstruct these for you.
Instances
data FieldModification (f :: Type -> Type) a #
A newtype wrapper around 'Columnar f a -> Columnar f ' (i.e., an
endomorphism between Columnar
s over f
). You usually want to use
fieldNamed
or the IsString
instance to rename the field, when 'f ~
TableField'
Instances
(Beamable tbl, RenamableField f) => RenamableWithRule (tbl (FieldModification f)) | |
Defined in Database.Beam.Schema.Tables renamingFields :: (NonEmpty Text -> Text) -> tbl (FieldModification f) # | |
IsString (FieldModification (TableField tbl) a) | |
Defined in Database.Beam.Schema.Tables fromString :: String -> FieldModification (TableField tbl) a # |
data TableEntity (tbl :: (Type -> Type) -> Type) #
Instances
data DatabaseEntity be (db :: (Type -> Type) -> Type) entityType #
Represents a meta-description of a particular entityType. Mostly, a wrapper
around 'DatabaseEntityDescriptor be entityType', but carries around the
IsDatabaseEntity
dictionary.
Instances
Database be db => RenamableWithRule (db (EntityModification (DatabaseEntity be db) be)) | |
Defined in Database.Beam.Schema.Tables renamingFields :: (NonEmpty Text -> Text) -> db (EntityModification (DatabaseEntity be db) be) # | |
IsDatabaseEntity be entity => RenamableWithRule (EntityModification (DatabaseEntity be db) be entity) | |
Defined in Database.Beam.Schema.Tables renamingFields :: (NonEmpty Text -> Text) -> EntityModification (DatabaseEntity be db) be entity # | |
(Selector f, IsDatabaseEntity be x, DatabaseEntityDefaultRequirements be x) => GAutoDbSettings (S1 f (K1 R (DatabaseEntity be db x) :: Type -> Type) p) | |
Defined in Database.Beam.Schema.Tables autoDbSettings' :: S1 f (K1 R (DatabaseEntity be db x)) p |
type DatabaseSettings be (db :: (Type -> Type) -> Type) = db (DatabaseEntity be db) #
When parameterized by this entity tag, a database type will hold
meta-information on the Haskell mappings of database entities. Under the
hood, each entity type is transformed into its DatabaseEntityDescriptor
type. For tables this includes the table name as well as the corresponding
TableSettings
, which provides names for each column.
data Lenses (t :: (Type -> Type) -> Type) (f :: Type -> Type) x #
Instances
(Generic (sub m), Generic (sub (Lenses t m)), GTableLenses t m (Rep (sub m)) (Rep (sub (Lenses t m)))) => GTableLenses t m (K1 R (sub m) :: k -> Type) (K1 R (sub (Lenses t m)) :: Type -> Type) | |
(Generic (sub (Nullable m)), Generic (sub (Nullable (Lenses t m))), GTableLenses t m (Rep (sub (Nullable m))) (Rep (sub (Nullable (Lenses t m))))) => GTableLenses t m (K1 R (sub (Nullable m)) :: k -> Type) (K1 R (sub (Nullable (Lenses t m))) :: Type -> Type) | |
type family Columnar (f :: Type -> Type) x :: Type where ... #
A type family that we use to "tag" columns in our table datatypes.
This is what allows us to use the same table type to hold table data, describe table settings, derive lenses, and provide expressions.
The basic rules are
Columnar Identity x = x
Thus, any Beam table applied to Identity
will yield a simplified version of the data type, that contains
just what you'd expect.
The Nullable
type is used when referencing PrimaryKey
s that we want to include optionally.
For example, if we have a table with a PrimaryKey
, like the following
data BeamTableT f = BeamTableT { _refToAnotherTable :: PrimaryKey AnotherTableT f , ... }
we would typically be required to provide values for the PrimaryKey
embedded into BeamTableT
. We can use
Nullable
to lift this constraint.
data BeamTableT f = BeamTableT { _refToAnotherTable :: PrimaryKey AnotherTableT (Nullable f) , ... }
Now we can use justRef
and nothingRef
to refer to this table optionally. The embedded PrimaryKey
in _refToAnotherTable
automatically has its fields converted into Maybe
using Nullable
.
The last Columnar
rule is
Columnar f x = f x
Use this rule if you'd like to parameterize your table type over any other functor. For example, this is used in the query modules to write expressions such as 'TableT QExpr', which returns a table whose fields have been turned into query expressions.
The other rules are used within Beam to provide lenses and to expose the inner structure of the data type.
type C (f :: Type -> Type) a = Columnar f a #
A short type-alias for Columnar
. May shorten your schema definitions
data Columnar' (f :: Type -> Type) a #
If you declare a function 'Columnar f a -> b' and try to constrain your
function by a type class for f
, GHC will complain, because f
is
ambiguous in 'Columnar f a'. For example, 'Columnar Identity (Maybe a) ~
Maybe a' and 'Columnar (Nullable Identity) a ~ Maybe a', so given a type
'Columnar f a', we cannot know the type of f
.
Thus, if you need to know f
, you can instead use Columnar'
. Since its a
newtype, it carries around the f
paramater unambiguously. Internally, it
simply wraps 'Columnar f a'
data TableField (table :: (Type -> Type) -> Type) ty #
Metadata for a field of type ty
in table
.
Essentially a wrapper over the field name, but with a phantom type parameter, so that it forms an appropriate column tag.
Usually you use the defaultDbSettings
function to generate an appropriate
naming convention for you, and then modify it with withDbModification
if
necessary. Under this scheme, the field n be renamed using the IsString
instance for TableField
, or the fieldNamed
function.
Instances
type TableSettings (table :: (Type -> Type) -> Type) = table (TableField table) #
Represents a table that contains metadata on its fields. In particular,
each field of type 'Columnar f a' is transformed into 'TableField table a'.
You can get or update the name of each field by using the fieldName
lens.
type HaskellTable (table :: (Type -> Type) -> Type) = table Identity #
The regular Haskell version of the table. Equivalent to 'tbl Identity'
class (Typeable table, Beamable table, Beamable (PrimaryKey table)) => Table (table :: (Type -> Type) -> Type) where #
The big Kahuna! All beam tables implement this class.
The kind of all table types is '(* -> *) -> *'. This is because all table types are actually table type constructors.
Every table type takes in another type constructor, called the column tag, and uses that constructor to instantiate the column types.
See the documentation for Columnar
.
This class is mostly Generic-derivable. You need only specify a type for the table's primary key and a method to extract the primary key given the table.
An example table:
data BlogPostT f = BlogPost { _blogPostSlug :: Columnar f Text , _blogPostBody :: Columnar f Text , _blogPostDate :: Columnar f UTCTime , _blogPostAuthor :: PrimaryKey AuthorT f , _blogPostTagline :: Columnar f (Maybe Text) , _blogPostImageGallery :: PrimaryKey ImageGalleryT (Nullable f) } deriving Generic instance Beamable BlogPostT instance Table BlogPostT where data PrimaryKey BlogPostT f = BlogPostId (Columnar f Text) deriving Generic primaryKey = BlogPostId . _blogPostSlug instance Beamable (PrimaryKey BlogPostT)
We can interpret this as follows:
- The
_blogPostSlug
,_blogPostBody
,_blogPostDate
, and_blogPostTagline
fields are of typesErrorMessage
,ErrorMessage
,UTCTime
, and 'Maybe Text' respectfully. - Since
_blogPostSlug
,_blogPostBody
,_blogPostDate
,_blogPostAuthor
must be provided (i.e, they cannot containNothing
), they will be given SQL NOT NULL constraints._blogPostTagline
is declaredMaybe
soNothing
will be stored as NULL in the database._blogPostImageGallery
will be allowed to be empty because it uses theNullable
tag modifier. blogPostAuthor
references theAuthorT
table (not given here) and is required.blogPostImageGallery
references theImageGalleryT
table (not given here), but this relation is not required (i.e., it may beNothing
. SeeNullable
).
data PrimaryKey (table :: (Type -> Type) -> Type) (column :: Type -> Type) :: Type #
A data type representing the types of primary keys for this table.
In order to play nicely with the default deriving mechanism, this type must be an instance of Generic
.
primaryKey :: table column -> PrimaryKey table column #
Given a table, this should return the PrimaryKey from the table. By keeping this polymorphic over column, we ensure that the primary key values come directly from the table (i.e., they can't be arbitrary constants)
Instances
(Beamable d, Typeable d) => Table (SessionT d) Source # | |
Defined in TsWeb.Tables.Session data PrimaryKey (SessionT d) column :: Type # primaryKey :: SessionT d column -> PrimaryKey (SessionT d) column # |
class Beamable (table :: (Type -> Type) -> Type) #
Provides a number of introspection routines for the beam library. Allows us
to "zip" tables with different column tags together. Always instantiate an
empty Beamable
instance for tables, primary keys, and any type that you
would like to embed within either. See the
manual for more
information on embedding.
Instances
class (BeamBackend be, Monad m) => MonadBeam be (m :: Type -> Type) | m -> be where #
A class that ties together a monad with a particular backend
Provided here is a low-level interface for executing commands. The 'run*'
functions are wrapped by the appropriate functions in Query
.
This interface is very high-level and isn't meant to expose the full power
of the underlying database. Namely, it only supports simple data retrieval
strategies. More complicated strategies (for example, Postgres's COPY
)
are supported in individual backends. See the documentation of those
backends for more details.
:: FromBackendRow be x | |
=> BeamSqlBackendSyntax be | The query to run |
-> (m (Maybe x) -> m a) | Reader action that will be called with a function to fetch the next row |
-> m a |
Run a query determined by the given syntax, providing an action that will
be called to consume the results from the database (if any). The action
will get a reader action that can be used to fetch the next row. When
this reader action returns Nothing
, there are no rows left to consume.
When the reader action returns, the database result is freed.
runNoReturn :: BeamSqlBackendSyntax be -> m () #
Run the given command and don't consume any results. Useful for DML statements like INSERT, UPDATE, and DELETE, or DDL statements.
runReturningOne :: FromBackendRow be x => BeamSqlBackendSyntax be -> m (Maybe x) #
Run the given command and fetch the unique result. The result is
Nothing
if either no results are returned or more than one result is
returned.
runReturningList :: FromBackendRow be x => BeamSqlBackendSyntax be -> m [x] #
Run the given command, collect all the results, and return them as a
list. May be more convenient than runReturningMany
, but reads the entire
result set into memory.
Instances
class BeamBackend be => FromBackendRow be a where #
Nothing
fromBackendRow :: FromBackendRowM be a #
Parses a beam row. This should not fail, except in the case of
an internal bug in beam deserialization code. If it does fail,
this should throw a BeamRowParseError
.
valuesNeeded :: Proxy be -> Proxy a -> Int #
Instances
data Nullable (c :: Type -> Type) x #
Support for NULLable Foreign Key references.
data MyTable f = MyTable { nullableRef :: PrimaryKey AnotherTable (Nullable f) , ... } deriving (Generic, Typeable)
See Columnar
for more information.
Instances
(<-.) :: SqlUpdatable be s lhs rhs => lhs -> rhs -> QAssignment be s infix 4 #
Transaction option: provide WithTx to wrap operations in BEGIN/COMMIT, or NoTx to skip that.
data QueryResult a Source #
Result of a select operation. This will either succeed with a QSimply, or fail with a QError (probably then an error in the db connection or table definitions).
Instances
Eq a => Eq (QueryResult a) Source # | |
Defined in TsWeb.Db (==) :: QueryResult a -> QueryResult a -> Bool # (/=) :: QueryResult a -> QueryResult a -> Bool # | |
Show a => Show (QueryResult a) Source # | |
Defined in TsWeb.Db showsPrec :: Int -> QueryResult a -> ShowS # show :: QueryResult a -> String # showList :: [QueryResult a] -> ShowS # |
data ExecResult a Source #
The result of a select, insert, update, or delete operation. This adds a
constraint error to the QueryResult
, making it nicer to filter out
conflicts when handling errors.
Instances
Eq a => Eq (ExecResult a) Source # | |
Defined in TsWeb.Db (==) :: ExecResult a -> ExecResult a -> Bool # (/=) :: ExecResult a -> ExecResult a -> Bool # | |
Show a => Show (ExecResult a) Source # | |
Defined in TsWeb.Db showsPrec :: Int -> ExecResult a -> ShowS # show :: ExecResult a -> String # showList :: [ExecResult a] -> ShowS # |
runSelectReturningList :: (ReadOnlyM m, FromBackendRow Postgres a) => Sel a -> m [a] Source #
runSelectReturningOne :: (ReadOnlyM m, FromBackendRow Postgres a) => Sel a -> m (Maybe a) Source #
query :: ListContains n ReadOnlyPool xs => TxOpt -> RoPg a -> TsActionCtxT lts xs sessdata (QueryResult a) Source #
Run one or many Beam runSelectReturningList
or
runSelectReturningOne
operation(s) against a view's
ReadOnlyPool.
queryMaybe :: (ListContains n ReadOnlyPool xs, FromBackendRow Postgres a) => Sel a -> TsActionCtxT lts xs sessdata (QueryResult (Maybe a)) Source #
Run a single Beam select
, returning a single (Maybe) value
queryList :: (ListContains n ReadOnlyPool xs, FromBackendRow Postgres a) => Sel a -> TsActionCtxT lts xs sessdata (QueryResult [a]) Source #
Run a single Beam select
, returning a list of values
execute :: ListContains n ReadWritePool xs => TxOpt -> Pg a -> TsActionCtxT lts xs sessdata (ExecResult a) Source #
Run any arbitrary Pg
monad in the context of a view,
returning an ExecResult