Liking cljdoc? Tell your friends :D

What is 2-way-SQL

2-way SQL is a style of SQL templating where:

  • the file is still recognizable as SQL
  • sample literals remain in place
  • those literals are replaced at runtime by bind params or fragments

For example:

SELECT *
FROM users
WHERE id = /*$id*/1

Rendered with:

{:id 42}

becomes:

SELECT *
FROM users
WHERE id = ?

with params:

[42]

Why this style is useful:

  • SQL stays readable in code review
  • you can often run the template directly with its sample values
  • the final runtime query remains explicit

Bisql keeps the syntax deliberately small. It supports:

  • bind variables
  • collection binding in IN (...)
  • if / elseif / else / end
  • for ... separating ...
  • declaration metadata

Bisql does not try to become a full templating language.

See also:

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close