| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Arbiter.Core.Sql.Query
Description
A SQL query bundling its text, its positional parameters, and its row
decoder in one value. Built by the sql
quasiquoter in Arbiter.Core.Sql.QQ. The parameters and decoder use the
same Col-driven vocabulary as the profunctor codec in
Arbiter.Core.Codec.
Synopsis
- data Query a = Query {}
- raw :: Text -> Query ()
- param :: SomeParam -> Query ()
- rows :: RowCodec a -> Query () -> Query a
- rawRows :: RowCodec a -> Text -> Query a
- sepBy :: Text -> [Query ()] -> Query ()
- mwhen :: Monoid m => Bool -> m -> m
- numberPlaceholders :: Text -> Text
- class ToFragment a where
- toFragment :: a -> Query ()
Documentation
A parameterized query paired with the decoder for its result rows.
Constructors
| Query | |
Instances
Source #rows :: RowCodec a -> Query () -> Query a
Attach a handwritten row decoder to a parameterized fragment.
Source #rawRows :: RowCodec a -> Text -> Query a
Attach a decoder to literal, parameter-free SQL rendered as plain Text.
Source #sepBy :: Text -> [Query ()] -> Query ()
Join fragments with a separator, concatenating their text and parameters
in order. Used for WHERE ... AND ... and runtime-sized VALUES lists.
Source #mwhen :: Monoid m => Bool -> m -> m
The fragment under a true flag. mempty under a false one.
Source #numberPlaceholders :: Text -> Text
Rewrite the ? placeholders in a query's text to PostgreSQL positional
placeholders ($1, $2, ...) for libpq-based backends. The Nth ? maps to
the Nth entry of qParams.
Source #class ToFragment a where
Values a ${...} splice accepts: raw Text (a bare clause or table name)
or a Query fragment (whose parameters interleave at the splice site).
Methods
Source #toFragment :: a -> Query ()
Instances
| ToFragment Text Source # | |
Defined in Arbiter.Core.Sql.Query Methods Source #toFragment :: Text -> Query () | |
| ToFragment (Query ()) Source # | |
Defined in Arbiter.Core.Sql.Query Methods Source #toFragment :: Query () -> Query () | |