| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Database.Beam.Backend.SQL.BeamExtensions
Description
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 be m => MonadBeamInsertReturning be (m :: Type -> Type) | m -> be where
- runInsertReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlInsert be table -> (table (QExpr be ()) -> a) -> m [QExprToIdentity a]
- runInsertReturningList :: (MonadBeamInsertReturning be m, Beamable table, Projectible be (table (QExpr be ())), FromBackendRow be (table Identity)) => SqlInsert be table -> m [table Identity]
- class MonadBeam be m => MonadBeamUpdateReturning be (m :: Type -> Type) | m -> be where
- runUpdateReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlUpdate be table -> (table (QExpr be ()) -> a) -> m [QExprToIdentity a]
- runUpdateReturningList :: (MonadBeamUpdateReturning be m, Beamable table, Projectible be (table (QExpr be ())), FromBackendRow be (table Identity)) => SqlUpdate be table -> m [table Identity]
- class MonadBeam be m => MonadBeamDeleteReturning be (m :: Type -> Type) | m -> be where
- runDeleteReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlDelete be table -> (table (QExpr be ()) -> a) -> m [QExprToIdentity a]
- runDeleteReturningList :: (MonadBeamDeleteReturning be m, Beamable table, Projectible be (table (QExpr be ())), FromBackendRow be (table Identity)) => SqlDelete be table -> m [table Identity]
- class BeamSqlBackend be => BeamHasInsertOnConflict be where
- data SqlConflictTarget be (table :: (Type -> Type) -> Type)
- data SqlConflictAction be (table :: (Type -> Type) -> Type)
- insertOnConflict :: forall table (db :: (Type -> Type) -> Type) s. Beamable table => DatabaseEntity be db (TableEntity table) -> SqlInsertValues be (table (QExpr be s)) -> SqlConflictTarget be table -> SqlConflictAction be table -> SqlInsert be table
- anyConflict :: forall (table :: (Type -> Type) -> Type). SqlConflictTarget be table
- conflictingFields :: Projectible be proj => (table (QExpr be QInternal) -> proj) -> SqlConflictTarget be table
- conflictingFieldsWhere :: Projectible be proj => (table (QExpr be QInternal) -> proj) -> (forall s. table (QExpr be s) -> QExpr be s Bool) -> SqlConflictTarget be table
- onConflictDoNothing :: forall (table :: (Type -> Type) -> Type). SqlConflictAction be table
- onConflictUpdateSet :: Beamable table => (forall s. table (QField s) -> table (QExpr be s) -> QAssignment be s) -> SqlConflictAction be table
- onConflictUpdateSetWhere :: Beamable table => (forall s. table (QField s) -> table (QExpr be s) -> QAssignment be s) -> (forall s. table (QField s) -> table (QExpr be s) -> QExpr be s Bool) -> SqlConflictAction be table
- copyTableTo :: forall be proj (db :: (Type -> Type) -> Type) table s. (IsSqlCopyToSyntax (BeamSqlBackendCopyToSyntax be), ProjectibleWithPredicate AnyType () Text proj) => DatabaseEntity be db (TableEntity table) -> (table (QField s) -> proj) -> SqlCopyToParams (BeamSqlBackendCopyToSyntax be) -> SqlCopyTo be proj
- copySelectTo :: (IsSqlCopyToSyntax (BeamSqlBackendCopyToSyntax be), SqlCopyToSourceSelectSyntax (SqlCopyToSourceSyntax (BeamSqlBackendCopyToSyntax be)) ~ BeamSqlBackendSelectSyntax be) => SqlSelect be a -> SqlCopyToParams (BeamSqlBackendCopyToSyntax be) -> SqlCopyTo be a
- data SqlCopyTo be a
- copyTableFrom :: forall be proj (db :: (Type -> Type) -> Type) table s. (IsSqlCopyFromSyntax (BeamSqlBackendCopyFromSyntax be), ProjectibleWithPredicate AnyType () Text proj) => DatabaseEntity be db (TableEntity table) -> (table (QField s) -> proj) -> SqlCopyFromParams (BeamSqlBackendCopyFromSyntax be) -> SqlCopyFrom be proj
- data SqlCopyFrom be a
- class IsSqlCopyToSourceSyntax syntax where
- type SqlCopyToSourceSelectSyntax syntax
- copyTableToSyntax :: Maybe Text -> Text -> Maybe (NonEmpty Text) -> syntax
- copySelectToSyntax :: SqlCopyToSourceSelectSyntax syntax -> syntax
- class IsSqlCopyFromSourceSyntax syntax where
- class IsSqlCopyToSourceSyntax (SqlCopyToSourceSyntax cmd) => IsSqlCopyToSyntax cmd where
- type SqlCopyToSourceSyntax cmd
- type SqlCopyToParams cmd
- copyToStmt :: SqlCopyToSourceSyntax cmd -> SqlCopyToParams cmd -> cmd
- class IsSqlCopyFromSourceSyntax (SqlCopyFromSourceSyntax cmd) => IsSqlCopyFromSyntax cmd where
- type SqlCopyFromSourceSyntax cmd
- type SqlCopyFromParams cmd
- copyFromStmt :: SqlCopyFromSourceSyntax cmd -> SqlCopyFromParams cmd -> cmd
- type family BeamSqlBackendCopyToSyntax be
- type family BeamSqlBackendCopyFromSyntax be
- class MonadBeam be m => MonadBeamCopyTo be (m :: Type -> Type) | m -> be where
- class MonadBeam be m => MonadBeamCopyFrom be (m :: Type -> Type) | m -> be where
- runCopyFrom :: SqlCopyFrom be proj -> m ()
- type family SqlCopyToSourceSelectSyntax syntax
- type family SqlCopyToSourceSyntax cmd
- type family SqlCopyToParams cmd
- type family SqlCopyFromSourceSyntax cmd
- type family SqlCopyFromParams cmd
- copyTableToStream :: forall be proj (db :: (Type -> Type) -> Type) table s. (IsSqlCopyToStreamSyntax (BeamSqlBackendCopyToStreamSyntax be), ProjectibleWithPredicate AnyType () Text proj) => DatabaseEntity be db (TableEntity table) -> (table (QField s) -> proj) -> SqlCopyToStreamParams (BeamSqlBackendCopyToStreamSyntax be) -> SqlCopyToStream be proj
- copySelectToStream :: (IsSqlCopyToStreamSyntax (BeamSqlBackendCopyToStreamSyntax be), SqlCopyToSourceSelectSyntax (SqlCopyToStreamSourceSyntax (BeamSqlBackendCopyToStreamSyntax be)) ~ BeamSqlBackendSelectSyntax be) => SqlSelect be a -> SqlCopyToStreamParams (BeamSqlBackendCopyToStreamSyntax be) -> SqlCopyToStream be a
- data SqlCopyToStream be a
- copyTableFromStream :: forall be proj (db :: (Type -> Type) -> Type) table s. (IsSqlCopyFromStreamSyntax (BeamSqlBackendCopyFromStreamSyntax be), ProjectibleWithPredicate AnyType () Text proj) => DatabaseEntity be db (TableEntity table) -> (table (QField s) -> proj) -> SqlCopyFromStreamParams (BeamSqlBackendCopyFromStreamSyntax be) -> SqlCopyFromStream be proj
- data SqlCopyFromStream be a
- class IsSqlCopyToSourceSyntax (SqlCopyToStreamSourceSyntax cmd) => IsSqlCopyToStreamSyntax cmd where
- type SqlCopyToStreamSourceSyntax cmd
- type SqlCopyToStreamParams cmd
- copyToStreamStmt :: SqlCopyToStreamSourceSyntax cmd -> SqlCopyToStreamParams cmd -> cmd
- class IsSqlCopyFromSourceSyntax (SqlCopyFromStreamSourceSyntax cmd) => IsSqlCopyFromStreamSyntax cmd where
- type SqlCopyFromStreamSourceSyntax cmd
- type SqlCopyFromStreamParams cmd
- copyFromStreamStmt :: SqlCopyFromStreamSourceSyntax cmd -> SqlCopyFromStreamParams cmd -> cmd
- type family BeamSqlBackendCopyToStreamSyntax be
- type family BeamSqlBackendCopyFromStreamSyntax be
- class MonadBeam be m => MonadBeamCopyToStream be (m :: Type -> Type) | m -> be where
- runCopyToStream :: SqlCopyToStream be a -> (ByteString -> IO ()) -> m ()
- class MonadBeam be m => MonadBeamCopyFromStream be (m :: Type -> Type) | m -> be where
- runCopyFromStream :: SqlCopyFromStream be a -> IO (Maybe ByteString) -> m ()
- type family SqlCopyToStreamSourceSyntax cmd
- type family SqlCopyToStreamParams cmd
- type family SqlCopyFromStreamSourceSyntax cmd
- type family SqlCopyFromStreamParams cmd
- newtype SqlSerial a = SqlSerial {
- unSerial :: a
- onConflictUpdateInstead :: (BeamHasInsertOnConflict be, Beamable table, ProjectibleWithPredicate AnyType () (InaccessibleQAssignment be) proj) => (table (Const (InaccessibleQAssignment be) :: Type -> Type) -> proj) -> SqlConflictAction be table
- onConflictUpdateAll :: forall be (table :: (Type -> Type) -> Type). (BeamHasInsertOnConflict be, Beamable table) => SqlConflictAction be table
Documentation
class MonadBeam be m => MonadBeamInsertReturning be (m :: Type -> Type) | m -> be where Source #
MonadBeams that support returning data from the newly created rows of an
INSERT statement. Useful for discovering the real value of a defaulted
field (such as a serial primary key).
Methods
runInsertReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlInsert be table -> (table (QExpr be ()) -> a) -> m [QExprToIdentity a] Source #
Execute an INSERT statement and return a list of values projected from
the inserted rows. The projection function selects which columns are
returned: pass id to return the full row, or supply a custom
projection to return a subset.
Instances
runInsertReturningList :: (MonadBeamInsertReturning be m, Beamable table, Projectible be (table (QExpr be ())), FromBackendRow be (table Identity)) => SqlInsert be table -> m [table Identity] Source #
Execute an INSERT statement and return the inserted rows in full.
A convenience around runInsertReturningListWith that uses id as the
projection.
class MonadBeam be m => MonadBeamUpdateReturning be (m :: Type -> Type) | m -> be where Source #
MonadBeams that support returning data from the updated rows of an
UPDATE statement. Useful for observing the post-update values of the
affected rows.
Methods
runUpdateReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlUpdate be table -> (table (QExpr be ()) -> a) -> m [QExprToIdentity a] Source #
Execute an UPDATE statement and return a list of values projected from
the updated rows. The projection function selects which columns are
returned: pass id to return the full row, or supply a custom
projection to return a subset.
Instances
runUpdateReturningList :: (MonadBeamUpdateReturning be m, Beamable table, Projectible be (table (QExpr be ())), FromBackendRow be (table Identity)) => SqlUpdate be table -> m [table Identity] Source #
Execute an UPDATE statement and return the updated rows in full.
A convenience around runUpdateReturningListWith that uses id as the
projection.
class MonadBeam be m => MonadBeamDeleteReturning be (m :: Type -> Type) | m -> be where Source #
MonadBeams that support returning data from rows that will be deleted by
the given DELETE statement. Useful for deallocating resources based on
the value of deleted rows.
Methods
runDeleteReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlDelete be table -> (table (QExpr be ()) -> a) -> m [QExprToIdentity a] Source #
Execute a DELETE statement and return a list of values projected from
the deleted rows. The projection function selects which columns are
returned: pass id to return the full row, or supply a custom
projection to return a subset.
Instances
runDeleteReturningList :: (MonadBeamDeleteReturning be m, Beamable table, Projectible be (table (QExpr be ())), FromBackendRow be (table Identity)) => SqlDelete be table -> m [table Identity] Source #
Execute a DELETE statement and return the deleted rows in full.
A convenience around runDeleteReturningListWith that uses id as the
projection.
class BeamSqlBackend be => BeamHasInsertOnConflict be where Source #
Associated Types
data SqlConflictTarget be (table :: (Type -> Type) -> Type) Source #
Specifies the kind of constraint that must be violated for the action to occur
data SqlConflictAction be (table :: (Type -> Type) -> Type) Source #
What to do when an INSERT statement inserts a row into the table tbl
that violates a constraint.
Methods
insertOnConflict :: forall table (db :: (Type -> Type) -> Type) s. Beamable table => DatabaseEntity be db (TableEntity table) -> SqlInsertValues be (table (QExpr be s)) -> SqlConflictTarget be table -> SqlConflictAction be table -> SqlInsert be table Source #
anyConflict :: forall (table :: (Type -> Type) -> Type). SqlConflictTarget be table Source #
conflictingFields :: Projectible be proj => (table (QExpr be QInternal) -> proj) -> SqlConflictTarget be table Source #
conflictingFieldsWhere :: Projectible be proj => (table (QExpr be QInternal) -> proj) -> (forall s. table (QExpr be s) -> QExpr be s Bool) -> SqlConflictTarget be table Source #
onConflictDoNothing :: forall (table :: (Type -> Type) -> Type). SqlConflictAction be table Source #
onConflictUpdateSet :: Beamable table => (forall s. table (QField s) -> table (QExpr be s) -> QAssignment be s) -> SqlConflictAction be table Source #
onConflictUpdateSetWhere :: Beamable table => (forall s. table (QField s) -> table (QExpr be s) -> QAssignment be s) -> (forall s. table (QField s) -> table (QExpr be s) -> QExpr be s Bool) -> SqlConflictAction be table Source #
Support for copying to external files
Arguments
| :: forall be proj (db :: (Type -> Type) -> Type) table s. (IsSqlCopyToSyntax (BeamSqlBackendCopyToSyntax be), ProjectibleWithPredicate AnyType () Text proj) | |
| => DatabaseEntity be db (TableEntity table) | |
| -> (table (QField s) -> proj) | Projection from table to columns. If you want
to copy the entire table, use |
| -> SqlCopyToParams (BeamSqlBackendCopyToSyntax be) | Backend-specific options. The output is also determined by this value |
| -> SqlCopyTo be proj |
Express the copy from a table, to a destination (typically a file).
To copy the result of a SELECT query instead, see copySelectTo.
Since: 0.11.1.0
Arguments
| :: (IsSqlCopyToSyntax (BeamSqlBackendCopyToSyntax be), SqlCopyToSourceSelectSyntax (SqlCopyToSourceSyntax (BeamSqlBackendCopyToSyntax be)) ~ BeamSqlBackendSelectSyntax be) | |
| => SqlSelect be a | |
| -> SqlCopyToParams (BeamSqlBackendCopyToSyntax be) | Backend-specific options. The format is pinned by this value |
| -> SqlCopyTo be a |
Express the copy from the result of a SELECT statement to a destination
(typically a file). Use this when the source rows are produced by a query
rather than read directly from a table.
To copy a table, or a subset of columns, see copyTableTo.
Since: 0.11.1.0
A built file-mode COPY ... TO statement, ready to be executed by
runCopyTo. Construct via copyTableTo or copySelectTo; the table
and proj phantom parameters track which table the statement applies to
and which columns it projects.
Constructors
| SqlCopyTo !(BeamSqlBackendCopyToSyntax be) | |
| SqlCopyToNoColumns | A projection covering zero columns. |
Arguments
| :: forall be proj (db :: (Type -> Type) -> Type) table s. (IsSqlCopyFromSyntax (BeamSqlBackendCopyFromSyntax be), ProjectibleWithPredicate AnyType () Text proj) | |
| => DatabaseEntity be db (TableEntity table) | |
| -> (table (QField s) -> proj) | Projection from table to columns. If you want
to copy into the entire table, use |
| -> SqlCopyFromParams (BeamSqlBackendCopyFromSyntax be) | Backend-specific options. The format is pinned by this value |
| -> SqlCopyFrom be proj |
Express the copy to a table, from an external source (typically a file).
Since: 0.11.1.0
data SqlCopyFrom be a Source #
A built file-mode COPY ... FROM statement, ready to be executed by
runCopyFrom. Construct via copyTableFrom.
Constructors
| SqlCopyFrom !(BeamSqlBackendCopyFromSyntax be) | |
| SqlCopyFromNoColumns | A projection covering zero columns. |
class IsSqlCopyToSourceSyntax syntax where Source #
This class allows to express the source of a `COPY ... TO` statement. The options are either from a table (with a possible projection), or from the result of a select query.
Reused by both file-mode and streaming COPY: the source shape (a table or
a SELECT) is the same regardless of where the data ends up.
Associated Types
type SqlCopyToSourceSelectSyntax syntax Source #
Expected to be equal to `BeamSqlBackendSelectSyntax be`
Methods
copyTableToSyntax :: Maybe Text -> Text -> Maybe (NonEmpty Text) -> syntax Source #
copySelectToSyntax :: SqlCopyToSourceSelectSyntax syntax -> syntax Source #
class IsSqlCopyFromSourceSyntax syntax where Source #
This class allows to express the source of a `COPY ... FROM` statement. Reused by both file-mode and streaming COPY.
class IsSqlCopyToSourceSyntax (SqlCopyToSourceSyntax cmd) => IsSqlCopyToSyntax cmd where Source #
Statement-level syntax for backends that support COPY ... TO file.
Associated Types
type SqlCopyToSourceSyntax cmd Source #
The syntax for the source of the copy. For example, in Postgres, this can be either a table (and optional projection), or a select statement.
type SqlCopyToParams cmd Source #
All backend-specific options which determine HOW the copy is performed, including the destination of the data (e.g. a filepath).
Methods
copyToStmt :: SqlCopyToSourceSyntax cmd -> SqlCopyToParams cmd -> cmd Source #
Combine a source and a parameters value into a complete
COPY ... TO ... statement.
class IsSqlCopyFromSourceSyntax (SqlCopyFromSourceSyntax cmd) => IsSqlCopyFromSyntax cmd where Source #
Statement-level syntax for backends that support file-mode COPY ... FROM file.
Symmetric to IsSqlCopyToSyntax, but the data flows in the opposite
direction: the params value supplies the source path and any
format-specific options.
Associated Types
type SqlCopyFromSourceSyntax cmd Source #
The syntax for the destination table of the copy.
type SqlCopyFromParams cmd Source #
All backend-specific options which determine HOW the copy is performed, including the source of the data (e.g. a filepath).
Methods
copyFromStmt :: SqlCopyFromSourceSyntax cmd -> SqlCopyFromParams cmd -> cmd Source #
Combine a destination and a parameters value into a complete
COPY ... FROM ... statement.
type family BeamSqlBackendCopyToSyntax be Source #
Type-family selector for the backend's file-mode COPY ... TO syntax.
A backend instance binds this to the concrete syntax type that implements
IsSqlCopyToSyntax.
type family BeamSqlBackendCopyFromSyntax be Source #
Type-family selector for the backend's file-mode COPY ... FROM syntax.
See BeamSqlBackendCopyToSyntax.
class MonadBeam be m => MonadBeamCopyTo be (m :: Type -> Type) | m -> be where Source #
MonadBeams that support copying data out of a database, to some other location.
See MonadBeamCopyFrom for the inverse operation.
Since: 0.11.1.0
Instances
| MonadBeamCopyTo be m => MonadBeamCopyTo be (ExceptT e m) Source # | |
| MonadBeamCopyTo be m => MonadBeamCopyTo be (ReaderT r m) Source # | |
| MonadBeamCopyTo be m => MonadBeamCopyTo be (StateT r m) Source # | |
| MonadBeamCopyTo be m => MonadBeamCopyTo be (StateT r m) Source # | |
| (MonadBeamCopyTo be m, Monoid r) => MonadBeamCopyTo be (WriterT r m) Source # | |
| (MonadBeamCopyTo be m, Monoid r) => MonadBeamCopyTo be (WriterT r m) Source # | |
| MonadBeamCopyTo be m => MonadBeamCopyTo be (ContT r m) Source # | |
| (MonadBeamCopyTo be m, Monoid w) => MonadBeamCopyTo be (RWST r w s m) Source # | |
| (MonadBeamCopyTo be m, Monoid w) => MonadBeamCopyTo be (RWST r w s m) Source # | |
class MonadBeam be m => MonadBeamCopyFrom be (m :: Type -> Type) | m -> be where Source #
MonadBeams that support copying data into database, from other location.
See MonadBeamCopyTo for the inverse operation.
Since: 0.11.1.0
Methods
runCopyFrom :: SqlCopyFrom be proj -> m () Source #
Execute a built COPY ... FROM file statement.
Instances
type family SqlCopyToSourceSelectSyntax syntax Source #
Expected to be equal to `BeamSqlBackendSelectSyntax be`
type family SqlCopyToSourceSyntax cmd Source #
The syntax for the source of the copy. For example, in Postgres, this can be either a table (and optional projection), or a select statement.
type family SqlCopyToParams cmd Source #
All backend-specific options which determine HOW the copy is performed, including the destination of the data (e.g. a filepath).
type family SqlCopyFromSourceSyntax cmd Source #
The syntax for the destination table of the copy.
type family SqlCopyFromParams cmd Source #
All backend-specific options which determine HOW the copy is performed, including the source of the data (e.g. a filepath).
Support for streaming copy
Arguments
| :: forall be proj (db :: (Type -> Type) -> Type) table s. (IsSqlCopyToStreamSyntax (BeamSqlBackendCopyToStreamSyntax be), ProjectibleWithPredicate AnyType () Text proj) | |
| => DatabaseEntity be db (TableEntity table) | |
| -> (table (QField s) -> proj) | Projection from table to columns. If you want
to copy the entire table, use |
| -> SqlCopyToStreamParams (BeamSqlBackendCopyToStreamSyntax be) | Backend-specific options. |
| -> SqlCopyToStream be proj |
Express a streaming copy from a table, the data flowing through the client connection rather than to a server-side file.
To stream the result of a SELECT query instead, see copySelectToStream.
Since: 0.11.1.0
copySelectToStream :: (IsSqlCopyToStreamSyntax (BeamSqlBackendCopyToStreamSyntax be), SqlCopyToSourceSelectSyntax (SqlCopyToStreamSourceSyntax (BeamSqlBackendCopyToStreamSyntax be)) ~ BeamSqlBackendSelectSyntax be) => SqlSelect be a -> SqlCopyToStreamParams (BeamSqlBackendCopyToStreamSyntax be) -> SqlCopyToStream be a Source #
Express a streaming copy from the result of a SELECT statement.
To stream a table, or a subset of columns, see copyTableToStream.
Since: 0.11.1.0
data SqlCopyToStream be a Source #
A built streaming-mode COPY ... TO statement, ready to be executed by
runCopyToStream.
Constructors
| SqlCopyToStream !(BeamSqlBackendCopyToStreamSyntax be) | |
| SqlCopyToStreamNoColumns | A projection covering zero columns. |
Arguments
| :: forall be proj (db :: (Type -> Type) -> Type) table s. (IsSqlCopyFromStreamSyntax (BeamSqlBackendCopyFromStreamSyntax be), ProjectibleWithPredicate AnyType () Text proj) | |
| => DatabaseEntity be db (TableEntity table) | |
| -> (table (QField s) -> proj) | Projection from which to copy columns. Other columns will have their default value inserted. To copy the stream into the entire table, use |
| -> SqlCopyFromStreamParams (BeamSqlBackendCopyFromStreamSyntax be) | |
| -> SqlCopyFromStream be proj |
Express a streaming copy into a table, the data flowing through the client connection rather than from a server-side file.
Since: 0.11.1.0
data SqlCopyFromStream be a Source #
A built streaming-mode COPY ... FROM statement, ready to be executed
by runCopyFromStream.
Constructors
| SqlCopyFromStream !(BeamSqlBackendCopyFromStreamSyntax be) | |
| SqlCopyFromStreamNoColumns | A projection covering zero columns. |
class IsSqlCopyToSourceSyntax (SqlCopyToStreamSourceSyntax cmd) => IsSqlCopyToStreamSyntax cmd where Source #
Statement-level syntax for backends that support streaming
COPY ... TO (data leaving the database through the client connection).
Mirrors IsSqlCopyToSyntax,
but the params value carries only format options — no destination path,
since chunks travel through the wire.
Associated Types
type SqlCopyToStreamSourceSyntax cmd Source #
The syntax for the source of the streaming copy. As with file-mode
COPY, this can be a table (perhaps with a projection) or a SELECT
query.
type SqlCopyToStreamParams cmd Source #
All backend-specific options which determine HOW the streaming copy is performed (format, delimiter, etc.). Unlike the file-mode params, there is no destination — chunks flow through the connection.
Methods
copyToStreamStmt :: SqlCopyToStreamSourceSyntax cmd -> SqlCopyToStreamParams cmd -> cmd Source #
Combine a source and a parameters value into a complete
streaming COPY ... TO stream statement.
class IsSqlCopyFromSourceSyntax (SqlCopyFromStreamSourceSyntax cmd) => IsSqlCopyFromStreamSyntax cmd where Source #
Statement-level syntax for backends that support streaming
COPY ... FROM (data entering the database through the client connection).
Mirrors IsSqlCopyFromSyntax.
Associated Types
type SqlCopyFromStreamSourceSyntax cmd Source #
The syntax for the destination table of the streaming copy.
type SqlCopyFromStreamParams cmd Source #
All backend-specific options which determine HOW the streaming copy is performed. Unlike the file-mode params, there is no source path — chunks flow through the connection.
Methods
copyFromStreamStmt :: SqlCopyFromStreamSourceSyntax cmd -> SqlCopyFromStreamParams cmd -> cmd Source #
Combine a destination and a parameters value into a complete
streaming COPY ... FROM stream statement.
type family BeamSqlBackendCopyToStreamSyntax be Source #
Type-family selector for the backend's streaming COPY ... TO syntax.
A backend instance binds this to the concrete syntax type that
implements IsSqlCopyToStreamSyntax.
type family BeamSqlBackendCopyFromStreamSyntax be Source #
Type-family selector for the backend's streaming COPY ... FROM syntax.
See BeamSqlBackendCopyToStreamSyntax.
class MonadBeam be m => MonadBeamCopyToStream be (m :: Type -> Type) | m -> be where Source #
MonadBeams that support streaming data out of a database through the
client connection (e.g. PostgreSQL's COPY ... TO STDOUT).
The supplied ByteString -> IO () callback is invoked once per chunk
received. The runCopyToStream call blocks until the COPY completes; on
failure it raises the underlying backend's exception.
See MonadBeamCopyFromStream for the inverse operation.
Since: 0.11.1.0
Methods
Arguments
| :: SqlCopyToStream be a | |
| -> (ByteString -> IO ()) | Sink. Called once for each chunk of bytes the server emits. |
| -> m () |
Execute a built streaming COPY ... TO stream statement. The supplied sink
is invoked from IO once per chunk emitted by the server, in order;
runCopyToStream returns once the server signals end of stream.
Instances
class MonadBeam be m => MonadBeamCopyFromStream be (m :: Type -> Type) | m -> be where Source #
MonadBeams that support streaming data into a database through the
client connection (e.g. PostgreSQL's COPY ... FROM STDIN).
The supplied IO (Maybe ByteString) source is pulled repeatedly until it
returns Nothing, signalling end of data. runCopyFromStream blocks
until the COPY commits; on failure it raises the underlying backend's
exception.
See MonadBeamCopyToStream for the inverse operation.
Since: 0.11.1.0
Methods
Arguments
| :: SqlCopyFromStream be a | |
| -> IO (Maybe ByteString) | Source. Called repeatedly. |
| -> m () |
Execute a built streaming COPY ... FROM statement. The supplied
producer is pulled from IO until it returns Nothing; each Just
chunk is forwarded to the server in order. runCopyFromStream returns
once the server has acknowledged the end of stream.
Instances
type family SqlCopyToStreamSourceSyntax cmd Source #
The syntax for the source of the streaming copy. As with file-mode
COPY, this can be a table (perhaps with a projection) or a SELECT
query.
type family SqlCopyToStreamParams cmd Source #
All backend-specific options which determine HOW the streaming copy is performed (format, delimiter, etc.). Unlike the file-mode params, there is no destination — chunks flow through the connection.
type family SqlCopyFromStreamSourceSyntax cmd Source #
The syntax for the destination table of the streaming copy.
type family SqlCopyFromStreamParams cmd Source #
All backend-specific options which determine HOW the streaming copy is performed. Unlike the file-mode params, there is no source path — chunks flow through the connection.
Instances
onConflictUpdateInstead :: (BeamHasInsertOnConflict be, Beamable table, ProjectibleWithPredicate AnyType () (InaccessibleQAssignment be) proj) => (table (Const (InaccessibleQAssignment be) :: Type -> Type) -> proj) -> SqlConflictAction be table Source #
onConflictUpdateAll :: forall be (table :: (Type -> Type) -> Type). (BeamHasInsertOnConflict be, Beamable table) => SqlConflictAction be table Source #