Primary API for HoneySQL 2.x.
This includes the format
function -- the primary entry point -- as well
as several public formatters that are intended to help users extend the
supported syntax.
In addition, functions to extend HoneySQL are also provided here:
clause-order
-- returns the current clause priority ordering;
intended as aid when registering new clauses.format-dsl
-- intended to format SQL statements; returns a vector
containing a SQL string followed by parameter values.format-entity
-- intended to format SQL entities; returns a string
representing the SQL entity.format-expr
-- intended to format SQL expressions; returns a vector
containing a SQL string followed by parameter values.format-expr-list
-- intended to format a list of SQL expressions;
returns a pair comprising: a sequence of SQL expressions (to be
join with a delimiter) and a sequence of parameter values.register-clause!
-- register a new statement/clause formatter.register-fn!
-- register a new function call (or special syntax)
formatter.register-op!
-- register a new operator formatter.set-dialect!
-- set the default dialect to be used for formatting,
and optionally set a global :quoted
option.sql-kw
-- turns a Clojure keyword (or symbol) into SQL code (makes
it uppercase and replaces - with space).Primary API for HoneySQL 2.x. This includes the `format` function -- the primary entry point -- as well as several public formatters that are intended to help users extend the supported syntax. In addition, functions to extend HoneySQL are also provided here: * `clause-order` -- returns the current clause priority ordering; intended as aid when registering new clauses. * `format-dsl` -- intended to format SQL statements; returns a vector containing a SQL string followed by parameter values. * `format-entity` -- intended to format SQL entities; returns a string representing the SQL entity. * `format-expr` -- intended to format SQL expressions; returns a vector containing a SQL string followed by parameter values. * `format-expr-list` -- intended to format a list of SQL expressions; returns a pair comprising: a sequence of SQL expressions (to be join with a delimiter) and a sequence of parameter values. * `register-clause!` -- register a new statement/clause formatter. * `register-fn!` -- register a new function call (or special syntax) formatter. * `register-op!` -- register a new operator formatter. * `set-dialect!` -- set the default dialect to be used for formatting, and optionally set a global `:quoted` option. * `sql-kw` -- turns a Clojure keyword (or symbol) into SQL code (makes it uppercase and replaces - with space).
Helper functions for the built-in clauses in honey.sql.
All helper functions are inherently variadic. Typical usage is threaded, like this:
(-> (select :a :b :c)
(from :table)
(where [:= :id 42])
(sql/format))
Therefore all helpers can take an existing DSL expression as their first argument or, if the first argument is not a hash map, an empty DSL is assumed -- an empty hash map. The above is therefore equivalent to:
(-> {}
(select :a :b :c)
(from :table)
(where [:= :id 42])
(sql/format))
Some of the helper functions here have :arglists
metadata
in an attempt to provide better hints for auto-complete in
editors but those :arglists
always omit the DSL argument
to avoid duplicating the various argument lists. When you
see an auto-complete suggestion like:
bulk-collect-into [varname] [varname n]
bear in mind that a DSL hash map can always be threaded in so the following (pseudo) arities are also available:
bulk-collect-into [dsl varname] [dsl varname n]
The actual arguments are:
bulk-collect-info [& args]
(as they are for all helper functions).
Helper functions for the built-in clauses in honey.sql. All helper functions are inherently variadic. Typical usage is threaded, like this: ``` (-> (select :a :b :c) (from :table) (where [:= :id 42]) (sql/format)) ``` Therefore all helpers can take an existing DSL expression as their first argument or, if the first argument is not a hash map, an empty DSL is assumed -- an empty hash map. The above is therefore equivalent to: ``` (-> {} (select :a :b :c) (from :table) (where [:= :id 42]) (sql/format)) ``` Some of the helper functions here have `:arglists` metadata in an attempt to provide better hints for auto-complete in editors but those `:arglists` _always omit the DSL argument_ to avoid duplicating the various argument lists. When you see an auto-complete suggestion like: bulk-collect-into [varname] [varname n] bear in mind that a DSL hash map can always be threaded in so the following (pseudo) arities are also available: bulk-collect-into [dsl varname] [dsl varname n] The actual arguments are: bulk-collect-info [& args] (as they are for all helper functions).
Register all the PostgreSQL JSON/JSONB operators and provide convenient Clojure names for those ops. In addition, provide names for the PostgreSQL regex operators as well.
For the eleven that cannot be written directly as symbols, use mnemonic names: hash for #, at for @, and tilde for ~.
For the six of those that cannot be written as
keywords, invoke the keyword
function instead.
Those latter eight (at>
, <at
, at?
, atat
,
tilde
, tilde*
, !tilde
, and !tilde*
) are
the only ones that should really be needed in the
DSL. The other names are provided for completeness.
regex
and iregex
are provided as aliases for the
regex operators tilde
and tilde*
respectively.
!regex
and !iregex
are provided as aliases for the
regex operators !tilde
and !tilde*
respectively.
Register all the PostgreSQL JSON/JSONB operators and provide convenient Clojure names for those ops. In addition, provide names for the PostgreSQL regex operators as well. For the eleven that cannot be written directly as symbols, use mnemonic names: hash for #, at for @, and tilde for ~. For the six of those that cannot be written as keywords, invoke the `keyword` function instead. Those latter eight (`at>`, `<at`, `at?`, `atat`, `tilde`, `tilde*`, `!tilde`, and `!tilde*`) are the only ones that should really be needed in the DSL. The other names are provided for completeness. `regex` and `iregex` are provided as aliases for the regex operators `tilde` and `tilde*` respectively. `!regex` and `!iregex` are provided as aliases for the regex operators `!tilde` and `!tilde*` respectively.
InlineValue -- a protocol that defines how to inline values; (sqlize x) produces a SQL string for x.
InlineValue -- a protocol that defines how to inline values; (sqlize x) produces a SQL string for x.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close