| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Arbiter.Core.Sql.QQ
Description
Internal to the arbiter packages. Not covered by the PVP.
The sql quasiquoter. It builds a Query whose text, parameters, and row
decoder all come from one template. The stmt quasiquoter renders the text once and makes each distinct
#{...} identifier a function argument.
Holes reference in-scope identifiers, like NeatInterpolation's ${var}:
${x}splices a fragment:Text(raw clause or table name) or aQuery ()(its parameters interleave at the splice site), viaToFragment.#{ident :: CInt8}emits one parameter hole and binds in-scopeidentas its value.Maybe CInt8,[CInt8], and[Maybe CInt8]pick the nullable, array, and nullable-array encoders.@{name :: CInt8}emits the identifiernameand addscol "name" CInt8to the decoder (Maybe CInt8usesncol). The quote's result type isQuery ()with no@{...}holes,Queryof the bare value with one, andQueryof a tuple with 2 tomaxOutputHoles.
A ? in the template is literal SQL. Do not use it in a template with holes.
The ?-placeholder form cannot tell it from a hole.
Synopsis
- sql :: QuasiQuoter
- stmt :: QuasiQuoter
- maxOutputHoles :: Int
Documentation
The sql quasiquoter, valid in expression position.
Like sql, but each distinct #{ident :: coltype} hole becomes a parameter of
the result, in order of first appearance. The text is rendered once.
The most @{...} holes one quote decodes as a tuple.