Copyright | Flipstone Technology Partners 2023 |
---|---|
License | MIT |
Stability | Stable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Functions for working with executable SELECT
statements. The Select
type is
a value that can be passed around and executed later. The Select
is directly
associated with how to decode the rows returned by the query. This means it
can be safely executed via executeSelect
and used to decode the rows. It is a
lower-level API than the entity select functions in
Orville.PostgreSQL.Execution.EntityOperations, but not as primitive as
Orville.PostgreSQL.Expr.Query.
Since: 1.0.0.0
Synopsis
- data Select readEntity
- executeSelect :: MonadOrville m => Select row -> m [row]
- useSelect :: (forall writeEntity. QueryExpr -> AnnotatedSqlMarshaller writeEntity readEntity -> a) -> Select readEntity -> a
- selectToQueryExpr :: Select readEntity -> QueryExpr
- selectTable :: TableDefinition key writeEntity readEntity -> SelectOptions -> Select readEntity
- selectMarshalledColumns :: AnnotatedSqlMarshaller writeEntity readEntity -> Qualified TableName -> SelectOptions -> Select readEntity
- rawSelectQueryExpr :: AnnotatedSqlMarshaller writeEntity readEntity -> QueryExpr -> Select readEntity
Documentation
data Select readEntity Source #
Represents a SELECT
statement that can be executed against a database. A
Select
has a SqlMarshaller
bound to it that will be
used to decode the database result set when it is executed.
Since: 1.0.0.0
executeSelect :: MonadOrville m => Select row -> m [row] Source #
Executes the database query for the Select
and uses its
SqlMarshaller
to decode the result set.
Since: 1.0.0.0
useSelect :: (forall writeEntity. QueryExpr -> AnnotatedSqlMarshaller writeEntity readEntity -> a) -> Select readEntity -> a Source #
Runs a function allowing it to use the data elements containted within the
Select
it pleases. The marshaller that the function is provided can be use
to decode results from the query.
Since: 1.0.0.0
selectToQueryExpr :: Select readEntity -> QueryExpr Source #
Extracts the query that will be run when the select 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
selectTable :: TableDefinition key writeEntity readEntity -> SelectOptions -> Select readEntity Source #
Builds a Select
that will select all the columns described in the
TableDefinition
. This is the safest way to build a Select
, because table
name and columns are all read from the TableDefinition
. If the table is
being managed with Orville auto-migrations, this will match the schema in the
database.
Since: 1.0.0.0
selectMarshalledColumns :: AnnotatedSqlMarshaller writeEntity readEntity -> Qualified TableName -> SelectOptions -> Select readEntity Source #
Builds a Select
that will select the columns described by the marshaller
from the specified table. It is up to the caller to ensure that the columns
in the marshaller make sense for the table.
This function is useful for querying a subset of table columns using a custom marshaller.
Since: 1.0.0.0
rawSelectQueryExpr :: AnnotatedSqlMarshaller writeEntity readEntity -> QueryExpr -> Select readEntity Source #
Builds a Select
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 QueryExpr
makes sense and produces a result set
that the SqlMarshaller
can decode.
This is the lowest level of escape hatch available for Select
. The caller
can build any query that Orville supports using the expression-building
functions, or use RawSql.fromRawSql
to build a raw QueryExpr
.
Since: 1.0.0.0