arbiter-core-0.1.0.0
arbiter-core
Safe HaskellNone
LanguageGHC2024

Arbiter.Core.Sql.QQ

Description

The sql quasiquoter. It builds a Query whose text, parameters, and row decoder all come from one template.

Holes reference in-scope identifiers, like NeatInterpolation's ${var}:

  • ${x} splices a fragment: Text (raw clause or table name) or a Query () (its parameters interleave at the splice site), via ToFragment.
  • #{ident :: CInt8} emits one ? and binds in-scope ident as a parameter. Maybe CInt8, [CInt8], and [Maybe CInt8] pick the nullable, array, and nullable-array encoders.
  • @{name :: CInt8} emits the identifier name and adds col "name" CInt8 to the decoder (Maybe CInt8 uses ncol). The quote's result type is Query of the tuple of these holes, or Query () when there are none.

A bare ? is rejected. Every placeholder comes from a hole. Use jsonb_exists and friends for jsonb key-existence.

Synopsis

Documentation

Source #sql :: QuasiQuoter

The sql quasiquoter, valid in expression position.