| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Database.PostgreSQL.Simple.SqlQQ.Interpolated
Description
Interpolated SQL queries
Synopsis
Documentation
isql :: QuasiQuoter Source #
Quote a SQL statement with embedded antiquoted expressions.
The result of the quasiquoter is a tuple, containing the statement string and a list of parameters. For example:
[isql|SELECT field FROM table WHERE name = ${map toLower ELLIOT} LIMIT ${10}|]produces
("SELECT field FROM table WHERE name = ? LIMIT ?", [Escape "elliot", Plain "10"])How the parser works:
Any expression occurring between ${ and } will be replaced with a ?
and passed as a query parameter.
Characters preceded by a backslash are treated literally. This enables the
inclusion of the literal substring ${ within your quoted text by writing
it as \${. The literal sequence \${ may be written as \\${.
Note: This quasiquoter is a wrapper around sql
which also "minifies" the query at compile time by stripping whitespace and
comments. However, there are a few "gotchas" to be aware of so please refer
to the documentation of that function for a full specification.
This quasiquoter only works in expression contexts and will throw an error at compile time if used in any other context.