arbiter-core-0.1.0.0
arbiter-core
Safe HaskellNone
LanguageGHC2024

Arbiter.Core.Sql.Query

Description

Internal to the arbiter packages. Not covered by the PVP.

A SQL query bundling its text, its positional parameters, and its row decoder in one value. The text is a list of literals and parameter holes, rendered in the placeholder form each backend needs. 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

Documentation

data Query aSource #

A parameterized query paired with the decoder for its result rows.

Constructors

Query 

Fields

Instances

Instances details
Functor Query Source # 
Instance details

Defined in Arbiter.Core.Sql.Query

Methods

fmap :: (a -> b) -> Query a -> Query b#

(<$) :: a -> Query b -> Query a#

ToFragment (Query ()) Source # 
Instance details

Defined in Arbiter.Core.Sql.Query

Methods

toFragment :: Query () -> Query ()Source #

Monoid (Query ()) Source # 
Instance details

Defined in Arbiter.Core.Sql.Query

Methods

mempty :: Query ()#

mappend :: Query () -> Query () -> Query ()#

mconcat :: [Query ()] -> Query ()#

Semigroup (Query ()) Source #

Concatenation is defined for Query (), a fragment with text and parameters and no output columns.

Instance details

Defined in Arbiter.Core.Sql.Query

Methods

(<>) :: Query () -> Query () -> Query ()#

sconcat :: NonEmpty (Query ()) -> Query ()#

stimes :: Integral b => b -> Query () -> Query ()#

mkQuery :: [Piece] -> Params -> RowCodec a -> Query aSource #

A query from its pieces, parameters and decoder.

raw :: Text -> Query ()Source #

Literal SQL with no parameters (table names, static clauses).

param :: SomeParam -> Query ()Source #

One hole bound to a single parameter.

rows :: RowCodec a -> Query () -> Query aSource #

Attach a handwritten row decoder to a parameterized fragment.

rawRows :: RowCodec a -> Text -> Query aSource #

Attach a decoder to literal, parameter-free SQL rendered as plain Text.

sepBy :: Text -> [Query ()] -> Query ()Source #

Join fragments with a separator, concatenating their text and parameters in order.

mwhen :: Monoid m => Bool -> m -> mSource #

The fragment under a true flag. mempty under a false one.

data PieceSource #

One run of literal SQL or one parameter hole.

Constructors

Lit !Text

Literal SQL text.

Hole

A parameter hole.

Instances

Instances details
Eq Piece Source # 
Instance details

Defined in Arbiter.Core.Sql.Query

Methods

(==) :: Piece -> Piece -> Bool#

(/=) :: Piece -> Piece -> Bool#

Show Piece Source # 
Instance details

Defined in Arbiter.Core.Sql.Query

class ToFragment a whereSource #

Values a ${...} splice accepts: raw Text (a bare clause or table name) or a Query fragment (whose parameters interleave at the splice site).

Methods

toFragment :: a -> Query ()Source #

The value as a fragment.

Instances

Instances details
ToFragment Text Source # 
Instance details

Defined in Arbiter.Core.Sql.Query

Methods

toFragment :: Text -> Query ()Source #

ToFragment (Query ()) Source # 
Instance details

Defined in Arbiter.Core.Sql.Query

Methods

toFragment :: Query () -> Query ()Source #