| Copyright | Flipstone Technology Partners 2023 |
|---|---|
| License | MIT |
| Stability | Stable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Orville.PostgreSQL.Execution.Delete
Description
Functions for working with executable DELETE statements. The Delete type is
a value that can be passed around and executed later. The Delete is directly
associated with the presence of a returning clause and how to decode any rows
returned by that clause. This means it can be safely executed via
executeDelete or executeDeleteReturnEntities as appropriate. It is a lower-level
API than the entity delete functions in
Orville.PostgreSQL.Execution.EntityOperations, but not as primitive as
Orville.PostgreSQL.Expr.Delete.
Since: 1.0.0.0
Synopsis
- data Delete readEntity returningClause
- deleteFromDeleteExpr :: Delete readEntity returningClause -> DeleteExpr
- executeDelete :: MonadOrville m => Delete readEntity NoReturningClause -> m Int
- executeDeleteReturnEntities :: MonadOrville m => Delete readEntity ReturningClause -> m [readEntity]
- deleteFromTableReturning :: TableDefinition key writeEntity readEntity -> Maybe BooleanExpr -> Delete readEntity ReturningClause
- deleteFromTable :: TableDefinition key writeEntity readEntity -> Maybe BooleanExpr -> Delete readEntity NoReturningClause
- rawDeleteExpr :: ReturningOption returningClause -> AnnotatedSqlMarshaller writeEntity readEntity -> DeleteExpr -> Delete readEntity returningClause
Documentation
data Delete readEntity returningClause Source #
Represents a DELETE statement that can be executed against a database. A
Delete has a SqlMarshaller bound to it that, when the
delete returns data from the database, will be used to decode the database
result set when it is executed.
Since: 1.0.0.0
deleteFromDeleteExpr :: Delete readEntity returningClause -> DeleteExpr Source #
Extracts the query that will be run when the delete is executed. Normally you don't want to extract the query and run it yourself, but this function is useful to view the query for debugging or query explanation.
Since: 1.0.0.0
executeDelete :: MonadOrville m => Delete readEntity NoReturningClause -> m Int Source #
Executes the database query for the Delete and returns the number of
rows affected by the query.
Since: 1.0.0.0
executeDeleteReturnEntities :: MonadOrville m => Delete readEntity ReturningClause -> m [readEntity] Source #
Executes the database query for the Delete and uses its
SqlMarshaller to decode the rows (that were just deleted)
as returned via a RETURNING clause.
Since: 1.0.0.0
deleteFromTableReturning :: TableDefinition key writeEntity readEntity -> Maybe BooleanExpr -> Delete readEntity ReturningClause Source #
Builds a Delete that will delete all of the writable columns described in the
TableDefinition and return the data as seen by the database. This is useful for getting
database-managed columns such as auto-incrementing identifiers and sequences.
Since: 1.0.0.0
deleteFromTable :: TableDefinition key writeEntity readEntity -> Maybe BooleanExpr -> Delete readEntity NoReturningClause Source #
Builds a Delete that will delete all of the writable columns described in the
TableDefinition without returning the data as seen by the database.
Since: 1.0.0.0
rawDeleteExpr :: ReturningOption returningClause -> AnnotatedSqlMarshaller writeEntity readEntity -> DeleteExpr -> Delete readEntity returningClause Source #
Builds a Delete that will execute the specified query and use the given
SqlMarshaller to decode it. It is up to the caller to
ensure that the given DeleteExpr makes sense and returns a result that
the SqlMarshaller can decode.
This is the lowest level of escape hatch available for Delete. The caller can build any query
that Orville supports using the expression-building functions, or use RawSql.fromRawSql to build
a raw DeleteExpr. It is expected that the ReturningOption given matches the
DeleteExpr. This level of interface does not provide an automatic enforcement of the
expectation, however failure is likely if that is not met.
Since: 1.0.0.0