Copyright | (c) Eitan Chatav 2019 |
---|---|
Maintainer | eitan@morphism.tech |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
A top-level Statement
type wraps a Query
or Manipulation
together with an EncodeParams
and a DecodeRow
.
Synopsis
- data Statement db x y where
- Manipulation :: (All (OidOfNull db) params, SListI row) => EncodeParams db params x -> DecodeRow row y -> Manipulation '[] db params row -> Statement db x y
- Query :: (All (OidOfNull db) params, SListI row) => EncodeParams db params x -> DecodeRow row y -> Query '[] '[] db params row -> Statement db x y
- query :: (GenericParams db params x xs, GenericRow row y ys) => Query '[] '[] db params row -> Statement db x y
- manipulation :: (GenericParams db params x xs, GenericRow row y ys) => Manipulation '[] db params row -> Statement db x y
- data Prepared m x y = Prepared {
- runPrepared :: x -> m y
- deallocate :: m ()
Statement
data Statement db x y where Source #
A Statement
consists of a Manipulation
or a Query
that can be run
in a MonadPQ
.
Manipulation | Constructor for a data manipulation language |
| |
Query | Constructor for a structured query language |
Instances
Profunctor (Statement db) Source # | |
Defined in Squeal.PostgreSQL.Session.Statement dimap :: (a -> b) -> (c -> d) -> Statement db b c -> Statement db a d # lmap :: (a -> b) -> Statement db b c -> Statement db a c # rmap :: (b -> c) -> Statement db a b -> Statement db a c # (#.) :: forall a b c q. Coercible c b => q b c -> Statement db a b -> Statement db a c # (.#) :: forall a b c q. Coercible b a => Statement db b c -> q a b -> Statement db a c # | |
Functor (Statement db x) Source # | |
RenderSQL (Statement db x y) Source # | |
Defined in Squeal.PostgreSQL.Session.Statement renderSQL :: Statement db x y -> ByteString Source # |
:: (GenericParams db params x xs, GenericRow row y ys) | |
=> Query '[] '[] db params row | |
-> Statement db x y |
Smart constructor for a structured query language Statement
:: (GenericParams db params x xs, GenericRow row y ys) | |
=> Manipulation '[] db params row |
|
-> Statement db x y |
Smart constructor for a data manipulation language Statement
Prepared
prepare
and
prepare_
create a Prepared
statement.
A Prepared
statement is a server-side object
that can be used to optimize performance.
When prepare
or prepare_
is executed,
the specified Statement
is parsed, analyzed, and rewritten.
When the runPrepared
command is subsequently issued,
the Prepared
statement is planned and executed.
This division of labor avoids repetitive parse analysis work,
while allowing the execution plan to
depend on the specific parameter values supplied.
Prepared
statements only last for the duration
of the current database session.
Prepared
statements can be manually cleaned up
using the deallocate
command.
Prepared | |
|