Rendering is the process of turning:
into:
Rendering returns a map like this:
{:sql "SELECT * FROM users WHERE id = ?"
:params [42]
:meta {}}
If declaration comments exist, :meta contains them.
WHERE id = /*$id*/1
{:id 42}
→
{:sql "WHERE id = ?"
:params [42]}
WHERE id IN /*$ids*/(1,2,3)
{:ids [10 20 30]}
→
{:sql "WHERE id IN (?, ?, ?)"
:params [10 20 30]}
WHERE
/*%if active */
active = true
/*%else => status = 'inactive' */
/*%end */
The rendered SQL depends on the truthiness of active.
DEFAULT and ALLbisql/DEFAULT and bisql/ALL are rendered as SQL keywords for scalar $ bindings.
{:status bisql/DEFAULT
:limit bisql/ALL}
LIKE_* HelpersBisql also provides small helpers for LIKE bindings:
bisql/LIKE_STARTS_WITHbisql/LIKE_ENDS_WITHbisql/LIKE_CONTAINSFor example:
WHERE name LIKE /*$search*/'foo%' ESCAPE '\'
{:search (bisql/LIKE_CONTAINS "foo%_bar")}
→
{:sql "WHERE name LIKE ? ESCAPE '\\'"
:params ["%foo\\%\\_bar%"]}
These helpers:
% in the expected position%_\They are intended for scalar $ bindings.
Typical user-facing APIs are:
bisql.core/defrenderbisql.core/defqueryFor lower-level examples, see:
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |