Liking cljdoc? Tell your friends :D

Bisql

Clojars Project Docs Ask DeepWiki

Bisql bicycle logo

bisql (báisikl)

Executable SQL as Clojure functions, with generated CRUD queries and SQL-first development.

SQL transformation screenshot

  • Query templates remain valid, executable SQL.
  • Typical index-friendly queries are generated automatically, as comprehensively as possible.

No query builder
No data mapper
No hidden SQL
No boilerplate SQL

Start a database, run the generation commands, add (defquery), and you can immediately call query functions from your Clojure code. Every function still corresponds to real SQL.

note

This project is still early and the API may change. Support for databases beyond PostgreSQL and Malli integration are both planned.

Getting Started

The full Getting Started guide lives here:

Installation

The full Installation guide lives here:

Malli Validation

  • Generated CRUD SQL carries :malli/in and :malli/out declaration metadata.
  • When generated query functions keep :malli/in and :malli/out metadata, Bisql can run Malli validation transparently during query execution.

The full guide lives here:

Quick Example

See the end-to-end sample project here:

It shows a practical flow:

  • generate CRUD SQL from a PostgreSQL schema
  • generate matching function namespace files
  • execute one generated query
  • copy one generated query into a hand-written SQL template
  • execute the customized query

Development

For local setup, tasks, and dev workflow, see:

Ideas Under Consideration

  • ✅️ ~~Support a very small expression language to improve expressiveness in if conditions.~~
  • ✅️ ~~Add Malli integration.~~
  • Split Malli validation dependencies out from the main runtime package.
  • Add sentinels for SQL time literals such as CURRENT_DATE, CURRENT_TIME, and CURRENT_TIMESTAMP.
  • Split the CLI into a separate package.
    • Add rewrite-clj as a CLI-side dependency and implement pruning for unused generated vars.
  • Support databases beyond PostgreSQL.
  • Compile analyzed SQL templates into reusable renderer functions for lower runtime overhead.
    • Simplify emitted renderer forms further, especially around branch and loop body handling.
    • Reduce helper calls in emitted code where fragment normalization is still delegated.
    • Restrict bisql/DEFAULT to valid SQL value contexts if context-aware rendering becomes necessary.
    • Detect dangerous nil comparisons consistently in WHERE / HAVING clauses instead of letting expressions such as = NULL, LIKE NULL, or IN (NULL) silently behave unexpectedly. This likely needs stricter SQL context parsing, because = NULL is dangerous in WHERE / HAVING but can still be valid assignment syntax in SET.

Can you improve this documentation? These fine people already did:
FumihikoHata & fumi hata
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