beam-core-0.11.1.0: Type-safe, feature-complete SQL query and manipulation interface for Haskell
Safe HaskellNone
LanguageHaskell2010

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

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

Instances details
MonadBeamInsertReturning be m => MonadBeamInsertReturning be (ExceptT e m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runInsertReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlInsert be table -> (table (QExpr be ()) -> a) -> ExceptT e m [QExprToIdentity a] Source #

MonadBeamInsertReturning be m => MonadBeamInsertReturning be (ReaderT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runInsertReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlInsert be table -> (table (QExpr be ()) -> a) -> ReaderT r m [QExprToIdentity a] Source #

MonadBeamInsertReturning be m => MonadBeamInsertReturning be (StateT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runInsertReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlInsert be table -> (table (QExpr be ()) -> a) -> StateT r m [QExprToIdentity a] Source #

MonadBeamInsertReturning be m => MonadBeamInsertReturning be (StateT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runInsertReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlInsert be table -> (table (QExpr be ()) -> a) -> StateT r m [QExprToIdentity a] Source #

(MonadBeamInsertReturning be m, Monoid r) => MonadBeamInsertReturning be (WriterT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runInsertReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlInsert be table -> (table (QExpr be ()) -> a) -> WriterT r m [QExprToIdentity a] Source #

(MonadBeamInsertReturning be m, Monoid r) => MonadBeamInsertReturning be (WriterT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runInsertReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlInsert be table -> (table (QExpr be ()) -> a) -> WriterT r m [QExprToIdentity a] Source #

MonadBeamInsertReturning be m => MonadBeamInsertReturning be (ContT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runInsertReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlInsert be table -> (table (QExpr be ()) -> a) -> ContT r m [QExprToIdentity a] Source #

(MonadBeamInsertReturning be m, Monoid w) => MonadBeamInsertReturning be (RWST r w s m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runInsertReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlInsert be table -> (table (QExpr be ()) -> a) -> RWST r w s m [QExprToIdentity a] Source #

(MonadBeamInsertReturning be m, Monoid w) => MonadBeamInsertReturning be (RWST r w s m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runInsertReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlInsert be table -> (table (QExpr be ()) -> a) -> RWST r w s m [QExprToIdentity a] Source #

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

Instances details
MonadBeamUpdateReturning be m => MonadBeamUpdateReturning be (ExceptT e m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runUpdateReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlUpdate be table -> (table (QExpr be ()) -> a) -> ExceptT e m [QExprToIdentity a] Source #

MonadBeamUpdateReturning be m => MonadBeamUpdateReturning be (ReaderT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runUpdateReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlUpdate be table -> (table (QExpr be ()) -> a) -> ReaderT r m [QExprToIdentity a] Source #

MonadBeamUpdateReturning be m => MonadBeamUpdateReturning be (StateT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runUpdateReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlUpdate be table -> (table (QExpr be ()) -> a) -> StateT r m [QExprToIdentity a] Source #

MonadBeamUpdateReturning be m => MonadBeamUpdateReturning be (StateT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runUpdateReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlUpdate be table -> (table (QExpr be ()) -> a) -> StateT r m [QExprToIdentity a] Source #

(MonadBeamUpdateReturning be m, Monoid r) => MonadBeamUpdateReturning be (WriterT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runUpdateReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlUpdate be table -> (table (QExpr be ()) -> a) -> WriterT r m [QExprToIdentity a] Source #

(MonadBeamUpdateReturning be m, Monoid r) => MonadBeamUpdateReturning be (WriterT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runUpdateReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlUpdate be table -> (table (QExpr be ()) -> a) -> WriterT r m [QExprToIdentity a] Source #

MonadBeamUpdateReturning be m => MonadBeamUpdateReturning be (ContT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runUpdateReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlUpdate be table -> (table (QExpr be ()) -> a) -> ContT r m [QExprToIdentity a] Source #

(MonadBeamUpdateReturning be m, Monoid w) => MonadBeamUpdateReturning be (RWST r w s m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runUpdateReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlUpdate be table -> (table (QExpr be ()) -> a) -> RWST r w s m [QExprToIdentity a] Source #

(MonadBeamUpdateReturning be m, Monoid w) => MonadBeamUpdateReturning be (RWST r w s m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runUpdateReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlUpdate be table -> (table (QExpr be ()) -> a) -> RWST r w s m [QExprToIdentity a] Source #

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

Instances details
MonadBeamDeleteReturning be m => MonadBeamDeleteReturning be (ExceptT e m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runDeleteReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlDelete be table -> (table (QExpr be ()) -> a) -> ExceptT e m [QExprToIdentity a] Source #

MonadBeamDeleteReturning be m => MonadBeamDeleteReturning be (ReaderT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runDeleteReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlDelete be table -> (table (QExpr be ()) -> a) -> ReaderT r m [QExprToIdentity a] Source #

MonadBeamDeleteReturning be m => MonadBeamDeleteReturning be (StateT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runDeleteReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlDelete be table -> (table (QExpr be ()) -> a) -> StateT r m [QExprToIdentity a] Source #

MonadBeamDeleteReturning be m => MonadBeamDeleteReturning be (StateT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runDeleteReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlDelete be table -> (table (QExpr be ()) -> a) -> StateT r m [QExprToIdentity a] Source #

(MonadBeamDeleteReturning be m, Monoid r) => MonadBeamDeleteReturning be (WriterT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runDeleteReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlDelete be table -> (table (QExpr be ()) -> a) -> WriterT r m [QExprToIdentity a] Source #

(MonadBeamDeleteReturning be m, Monoid r) => MonadBeamDeleteReturning be (WriterT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runDeleteReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlDelete be table -> (table (QExpr be ()) -> a) -> WriterT r m [QExprToIdentity a] Source #

MonadBeamDeleteReturning be m => MonadBeamDeleteReturning be (ContT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runDeleteReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlDelete be table -> (table (QExpr be ()) -> a) -> ContT r m [QExprToIdentity a] Source #

(MonadBeamDeleteReturning be m, Monoid w) => MonadBeamDeleteReturning be (RWST r w s m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runDeleteReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlDelete be table -> (table (QExpr be ()) -> a) -> RWST r w s m [QExprToIdentity a] Source #

(MonadBeamDeleteReturning be m, Monoid w) => MonadBeamDeleteReturning be (RWST r w s m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions

Methods

runDeleteReturningListWith :: (Beamable table, Projectible be a, FromBackendRow be (QExprToIdentity a)) => SqlDelete be table -> (table (QExpr be ()) -> a) -> RWST r w s m [QExprToIdentity a] Source #

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

copyTableTo Source #

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 id.

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

copySelectTo Source #

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

data SqlCopyTo be a Source #

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. runCopyTo should treat this as a no-op rather than emit an empty COPY tbl () TO ... statement.

copyTableFrom Source #

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 id.

-> 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. runCopyFrom should treat this as a no-op rather than emit an empty COPY tbl () FROM ... statement.

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`

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

Methods

runCopyTo :: SqlCopyTo be res -> m () Source #

Execute a built COPY ... TO file statement.

Instances

Instances details
MonadBeamCopyTo be m => MonadBeamCopyTo be (ExceptT e m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.File

Methods

runCopyTo :: SqlCopyTo be res -> ExceptT e m () Source #

MonadBeamCopyTo be m => MonadBeamCopyTo be (ReaderT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.File

Methods

runCopyTo :: SqlCopyTo be res -> ReaderT r m () Source #

MonadBeamCopyTo be m => MonadBeamCopyTo be (StateT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.File

Methods

runCopyTo :: SqlCopyTo be res -> StateT r m () Source #

MonadBeamCopyTo be m => MonadBeamCopyTo be (StateT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.File

Methods

runCopyTo :: SqlCopyTo be res -> StateT r m () Source #

(MonadBeamCopyTo be m, Monoid r) => MonadBeamCopyTo be (WriterT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.File

Methods

runCopyTo :: SqlCopyTo be res -> WriterT r m () Source #

(MonadBeamCopyTo be m, Monoid r) => MonadBeamCopyTo be (WriterT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.File

Methods

runCopyTo :: SqlCopyTo be res -> WriterT r m () Source #

MonadBeamCopyTo be m => MonadBeamCopyTo be (ContT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.File

Methods

runCopyTo :: SqlCopyTo be res -> ContT r m () Source #

(MonadBeamCopyTo be m, Monoid w) => MonadBeamCopyTo be (RWST r w s m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.File

Methods

runCopyTo :: SqlCopyTo be res -> RWST r w s m () Source #

(MonadBeamCopyTo be m, Monoid w) => MonadBeamCopyTo be (RWST r w s m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.File

Methods

runCopyTo :: SqlCopyTo be res -> 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

Instances details
MonadBeamCopyFrom be m => MonadBeamCopyFrom be (ExceptT e m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.File

Methods

runCopyFrom :: SqlCopyFrom be proj -> ExceptT e m () Source #

MonadBeamCopyFrom be m => MonadBeamCopyFrom be (ReaderT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.File

Methods

runCopyFrom :: SqlCopyFrom be proj -> ReaderT r m () Source #

MonadBeamCopyFrom be m => MonadBeamCopyFrom be (StateT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.File

Methods

runCopyFrom :: SqlCopyFrom be proj -> StateT r m () Source #

MonadBeamCopyFrom be m => MonadBeamCopyFrom be (StateT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.File

Methods

runCopyFrom :: SqlCopyFrom be proj -> StateT r m () Source #

(MonadBeamCopyFrom be m, Monoid r) => MonadBeamCopyFrom be (WriterT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.File

Methods

runCopyFrom :: SqlCopyFrom be proj -> WriterT r m () Source #

(MonadBeamCopyFrom be m, Monoid r) => MonadBeamCopyFrom be (WriterT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.File

Methods

runCopyFrom :: SqlCopyFrom be proj -> WriterT r m () Source #

MonadBeamCopyFrom be m => MonadBeamCopyFrom be (ContT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.File

Methods

runCopyFrom :: SqlCopyFrom be proj -> ContT r m () Source #

(MonadBeamCopyFrom be m, Monoid w) => MonadBeamCopyFrom be (RWST r w s m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.File

Methods

runCopyFrom :: SqlCopyFrom be proj -> RWST r w s m () Source #

(MonadBeamCopyFrom be m, Monoid w) => MonadBeamCopyFrom be (RWST r w s m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.File

Methods

runCopyFrom :: SqlCopyFrom be proj -> RWST r w s m () Source #

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

copyTableToStream Source #

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 id.

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

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. runCopyToStream should treat this as a no-op (it must still call the sink zero times) rather than emit an empty COPY tbl () TO STDOUT statement.

copyTableFromStream Source #

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 id.

-> 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. runCopyFromStream should treat this as a no-op (it should not pull from the source) rather than emit an empty COPY tbl () FROM STDIN statement.

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

runCopyToStream Source #

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

Instances details
MonadBeamCopyToStream be m => MonadBeamCopyToStream be (ExceptT e m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.Stream

Methods

runCopyToStream :: SqlCopyToStream be a -> (ByteString -> IO ()) -> ExceptT e m () Source #

MonadBeamCopyToStream be m => MonadBeamCopyToStream be (ReaderT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.Stream

Methods

runCopyToStream :: SqlCopyToStream be a -> (ByteString -> IO ()) -> ReaderT r m () Source #

MonadBeamCopyToStream be m => MonadBeamCopyToStream be (StateT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.Stream

Methods

runCopyToStream :: SqlCopyToStream be a -> (ByteString -> IO ()) -> StateT r m () Source #

MonadBeamCopyToStream be m => MonadBeamCopyToStream be (StateT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.Stream

Methods

runCopyToStream :: SqlCopyToStream be a -> (ByteString -> IO ()) -> StateT r m () Source #

(MonadBeamCopyToStream be m, Monoid r) => MonadBeamCopyToStream be (WriterT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.Stream

Methods

runCopyToStream :: SqlCopyToStream be a -> (ByteString -> IO ()) -> WriterT r m () Source #

(MonadBeamCopyToStream be m, Monoid r) => MonadBeamCopyToStream be (WriterT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.Stream

Methods

runCopyToStream :: SqlCopyToStream be a -> (ByteString -> IO ()) -> WriterT r m () Source #

MonadBeamCopyToStream be m => MonadBeamCopyToStream be (ContT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.Stream

Methods

runCopyToStream :: SqlCopyToStream be a -> (ByteString -> IO ()) -> ContT r m () Source #

(MonadBeamCopyToStream be m, Monoid w) => MonadBeamCopyToStream be (RWST r w s m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.Stream

Methods

runCopyToStream :: SqlCopyToStream be a -> (ByteString -> IO ()) -> RWST r w s m () Source #

(MonadBeamCopyToStream be m, Monoid w) => MonadBeamCopyToStream be (RWST r w s m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.Stream

Methods

runCopyToStream :: SqlCopyToStream be a -> (ByteString -> IO ()) -> RWST r w s m () Source #

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

runCopyFromStream Source #

Arguments

:: SqlCopyFromStream be a 
-> IO (Maybe ByteString)

Source. Called repeatedly. Nothing signals end of data.

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

Instances details
MonadBeamCopyFromStream be m => MonadBeamCopyFromStream be (ExceptT e m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.Stream

MonadBeamCopyFromStream be m => MonadBeamCopyFromStream be (ReaderT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.Stream

MonadBeamCopyFromStream be m => MonadBeamCopyFromStream be (StateT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.Stream

MonadBeamCopyFromStream be m => MonadBeamCopyFromStream be (StateT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.Stream

(MonadBeamCopyFromStream be m, Monoid r) => MonadBeamCopyFromStream be (WriterT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.Stream

(MonadBeamCopyFromStream be m, Monoid r) => MonadBeamCopyFromStream be (WriterT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.Stream

MonadBeamCopyFromStream be m => MonadBeamCopyFromStream be (ContT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.Stream

(MonadBeamCopyFromStream be m, Monoid w) => MonadBeamCopyFromStream be (RWST r w s m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.Stream

(MonadBeamCopyFromStream be m, Monoid w) => MonadBeamCopyFromStream be (RWST r w s m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.BeamExtensions.Copy.Stream

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.

newtype SqlSerial a Source #

Constructors

SqlSerial 

Fields

Instances

Instances details
FromBackendRow be x => FromBackendRow be (SqlSerial x) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.Row

HasSqlValueSyntax syntax x => HasSqlValueSyntax syntax (SqlSerial x) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.SQL92

Methods

sqlValueSyntax :: SqlSerial x -> syntax Source #

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

Defined in Database.Beam.Query.Ord

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

Defined in Database.Beam.Query.Ord

FromJSON a => FromJSON (SqlSerial a) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.Types

ToJSON a => ToJSON (SqlSerial a) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.Types

Enum a => Enum (SqlSerial a) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.Types

Generic (SqlSerial a) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.Types

Associated Types

type Rep (SqlSerial a) 
Instance details

Defined in Database.Beam.Backend.SQL.Types

type Rep (SqlSerial a) = D1 ('MetaData "SqlSerial" "Database.Beam.Backend.SQL.Types" "beam-core-0.11.1.0-inplace" 'True) (C1 ('MetaCons "SqlSerial" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSerial") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

Methods

from :: SqlSerial a -> Rep (SqlSerial a) x #

to :: Rep (SqlSerial a) x -> SqlSerial a #

Num a => Num (SqlSerial a) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.Types

Read a => Read (SqlSerial a) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.Types

Integral a => Integral (SqlSerial a) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.Types

Real a => Real (SqlSerial a) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.Types

Show a => Show (SqlSerial a) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.Types

Eq a => Eq (SqlSerial a) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.Types

Methods

(==) :: SqlSerial a -> SqlSerial a -> Bool #

(/=) :: SqlSerial a -> SqlSerial a -> Bool #

Ord a => Ord (SqlSerial a) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.Types

type Rep (SqlSerial a) Source # 
Instance details

Defined in Database.Beam.Backend.SQL.Types

type Rep (SqlSerial a) = D1 ('MetaData "SqlSerial" "Database.Beam.Backend.SQL.Types" "beam-core-0.11.1.0-inplace" 'True) (C1 ('MetaCons "SqlSerial" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSerial") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

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 #