Safe Haskell | None |
---|---|
Language | Haskell2010 |
Some functionality is useful enough to be provided across backends, but is not standardized. For example, many RDBMS systems provide ways of fetching auto-incrementing or defaulting fields on INSERT or UPDATE.
Beam provides type classes that some backends instantiate that provide this support. This uses direct means on sufficiently advanced backends and is emulated on others.
Synopsis
- class MonadBeam syntax be handle m => MonadBeamInsertReturning syntax be handle m | m -> syntax be handle, be -> m, handle -> m where
- class MonadBeam syntax be handle m => MonadBeamUpdateReturning syntax be handle m | m -> syntax be handle, be -> m, handle -> m where
- class MonadBeam syntax be handle m => MonadBeamDeleteReturning syntax be handle m | m -> syntax be handle, be -> m, handle -> m where
- newtype SqlSerial a = SqlSerial {
- unSerial :: a
Documentation
class MonadBeam syntax be handle m => MonadBeamInsertReturning syntax be handle m | m -> syntax be handle, be -> m, handle -> m where Source #
MonadBeam
s that support returning the newly created rows of an INSERT
statement.
Useful for discovering the real value of a defaulted value.
runInsertReturningList :: (Beamable table, Projectible (Sql92ExpressionSyntax syntax) (table (QExpr (Sql92ExpressionSyntax syntax) ())), FromBackendRow be (table Identity)) => DatabaseEntity be db (TableEntity table) -> SqlInsertValues (Sql92InsertValuesSyntax (Sql92InsertSyntax syntax)) (table (QExpr (Sql92InsertExpressionSyntax (Sql92InsertSyntax syntax)) s)) -> m [table Identity] Source #
class MonadBeam syntax be handle m => MonadBeamUpdateReturning syntax be handle m | m -> syntax be handle, be -> m, handle -> m where Source #
MonadBeam
s that support returning the updated rows of an UPDATE
statement.
Useful for discovering the new values of the updated rows.
runUpdateReturningList :: (Beamable table, Projectible (Sql92ExpressionSyntax syntax) (table (QExpr (Sql92ExpressionSyntax syntax) ())), FromBackendRow be (table Identity)) => DatabaseEntity be db (TableEntity table) -> (forall s. table (QField s) -> [QAssignment (Sql92UpdateFieldNameSyntax (Sql92UpdateSyntax syntax)) (Sql92UpdateExpressionSyntax (Sql92UpdateSyntax syntax)) s]) -> (forall s. table (QExpr (Sql92UpdateExpressionSyntax (Sql92UpdateSyntax syntax)) s) -> QExpr (Sql92UpdateExpressionSyntax (Sql92UpdateSyntax syntax)) s Bool) -> m [table Identity] Source #
class MonadBeam syntax be handle m => MonadBeamDeleteReturning syntax be handle m | m -> syntax be handle, be -> m, handle -> m where Source #
MonadBeam
s that suppert returning rows that will be deleted by the given
DELETE
statement. Useful for deallocating resources based on the value of
deleted rows.
runDeleteReturningList :: (Beamable table, Projectible (Sql92ExpressionSyntax syntax) (table (QExpr (Sql92ExpressionSyntax syntax) ())), FromBackendRow be (table Identity)) => DatabaseEntity be db (TableEntity table) -> (forall s. table (QExpr (Sql92UpdateExpressionSyntax (Sql92UpdateSyntax syntax)) s) -> QExpr (Sql92UpdateExpressionSyntax (Sql92UpdateSyntax syntax)) s Bool) -> m [table Identity] Source #