Liking cljdoc? Tell your friends :D

honey.sql

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.
  • 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.
* `sql-kw` -- turns a Clojure keyword (or symbol) into SQL code (makes
      it uppercase and replaces - with space). 
raw docstring

clause-orderclj/s

(clause-order)

Return the current order that known clauses will be applied when formatting a data structure into SQL. This may be useful when you are figuring out the before argument of register-clause! as well as for debugging new clauses you have registered.

Return the current order that known clauses will be applied when
formatting a data structure into SQL. This may be useful when you are
figuring out the `before` argument of `register-clause!` as well as
for debugging new clauses you have registered.
sourceraw docstring

formatclj/s

(format data)
(format data opts)
(format data k v & {:as opts})

Turn the data DSL into a vector containing a SQL string followed by any parameter values that were encountered in the DSL structure.

This is the primary API for HoneySQL and handles dialects, quoting, and named parameters.

format accepts options as either a single hash map argument or as named arguments (alternating keys and values). If you are using Clojure 1.11 (or later) you can mix'n'match, providing some options as named arguments followed by other options in a hash map.

Turn the data DSL into a vector containing a SQL string followed by
any parameter values that were encountered in the DSL structure.

This is the primary API for HoneySQL and handles dialects, quoting,
and named parameters.

`format` accepts options as either a single hash map argument or
as named arguments (alternating keys and values). If you are using
Clojure 1.11 (or later) you can mix'n'match, providing some options
as named arguments followed by other options in a hash map.
sourceraw docstring

format-dslclj/s

(format-dsl statement-map & [{:keys [aliased nested pretty]}])

Given a hash map representing a SQL statement and a hash map of options, return a vector containing a string -- the formatted SQL statement -- followed by any parameter values that SQL needs.

This is intended to be used when writing your own formatters to extend the DSL supported by HoneySQL.

Given a hash map representing a SQL statement and a hash map
of options, return a vector containing a string -- the formatted
SQL statement -- followed by any parameter values that SQL needs.

This is intended to be used when writing your own formatters to
extend the DSL supported by HoneySQL.
sourceraw docstring

format-entityclj/s

(format-entity e & [{:keys [aliased drop-ns]}])

Given a simple SQL entity (a keyword or symbol -- or string), return the equivalent SQL fragment (as a string -- no parameters).

Handles quoting, splitting at / or ., replacing - with _ etc.

Given a simple SQL entity (a keyword or symbol -- or string),
return the equivalent SQL fragment (as a string -- no parameters).

Handles quoting, splitting at / or ., replacing - with _ etc.
sourceraw docstring

format-exprclj/s

(format-expr expr & [{:keys [nested] :as opts}])

Given a data structure that represents a SQL expression and a hash map of options, return a vector containing a string -- the formatted SQL statement -- followed by any parameter values that SQL needs.

This is intended to be used when writing your own formatters to extend the DSL supported by HoneySQL.

Given a data structure that represents a SQL expression and a hash
map of options, return a vector containing a string -- the formatted
SQL statement -- followed by any parameter values that SQL needs.

This is intended to be used when writing your own formatters to
extend the DSL supported by HoneySQL.
sourceraw docstring

format-expr-listclj/s

(format-expr-list exprs & [opts])

Given a sequence of expressions represented as data, return a pair where the first element is a sequence of SQL fragments and the second element is a sequence of parameters. The caller should join the SQL fragments with whatever appropriate delimiter is needed and then return a vector whose first element is the complete SQL string and whose subsequent elements are the parameters:

(let [[sqls params] (format-expr-list data opts)] (into [(str/join delim sqls)] params))

This is intended to be used when writing your own formatters to extend the DSL supported by HoneySQL.

Given a sequence of expressions represented as data, return a pair
where the first element is a sequence of SQL fragments and the second
element is a sequence of parameters. The caller should join the SQL
fragments with whatever appropriate delimiter is needed and then
return a vector whose first element is the complete SQL string and
whose subsequent elements are the parameters:

(let [[sqls params] (format-expr-list data opts)]
  (into [(str/join delim sqls)] params))

This is intended to be used when writing your own formatters to
extend the DSL supported by HoneySQL.
sourceraw docstring

register-clause!clj/s

(register-clause! clause formatter before)

Register a new clause formatter. If before is nil, the clause is added to the end of the list of known clauses, otherwise it is inserted immediately prior to that clause.

New clauses are registered in the base order and the current order so that any dialect selections are able to include them while still working predictably from the base order. Caveat: that means if you register a new clause before a clause that is ordered differently in different dialects, your new clause may also end up in a different place. The only clause so far where that would matter is :set which differs in MySQL.

Use clause-order to see the full ordering of existing clauses.

Register a new clause formatter. If `before` is `nil`, the clause is
added to the end of the list of known clauses, otherwise it is inserted
immediately prior to that clause.

New clauses are registered in the base order and the current order so
that any dialect selections are able to include them while still working
predictably from the base order. Caveat: that means if you register a new
clause `before` a clause that is ordered differently in different
dialects, your new clause may also end up in a different place. The
only clause so far where that would matter is `:set` which differs in
MySQL.

Use `clause-order` to see the full ordering of existing clauses.
sourceraw docstring

register-fn!clj/s

(register-fn! function formatter)

Register a new function (as special syntax). The formatter is either a keyword, meaning that this new function should use the same syntax as an existing function, or a function of two arguments that generates a SQL string and parameters (as a vector). The two arguments are the name of the function (as a keyword) and a sequence of the arguments from the DSL.

Register a new function (as special syntax). The `formatter` is either
a keyword, meaning that this new function should use the same syntax as
an existing function, or a function of two arguments that generates a
SQL string and parameters (as a vector). The two arguments are the name
of the function (as a keyword) and a sequence of the arguments from the
DSL.
sourceraw docstring

register-op!clj/s

(register-op! op & {:keys [variadic ignore-nil]})

Register a new infix operator. Operators can be defined to be variadic (the default is that they are binary) and may choose to ignore nil arguments (this can make it easier to programmatically construct the DSL).

Register a new infix operator. Operators can be defined to be variadic (the
default is that they are binary) and may choose to ignore `nil` arguments
(this can make it easier to programmatically construct the DSL).
sourceraw docstring

set-dialect!clj/s

(set-dialect! dialect)

Set the default dialect for formatting.

Can be: :ansi (the default), :mysql, :oracle, or :sqlserver.

Dialects are always applied to the base order to create the current order.

Set the default dialect for formatting.

Can be: `:ansi` (the default), `:mysql`, `:oracle`, or `:sqlserver`.

Dialects are always applied to the base order to create the current order.
sourceraw docstring

sql-kwclj/s

(sql-kw k)

Given a keyword, return a SQL representation of it as a string.

A :kebab-case keyword becomes a KEBAB CASE (uppercase) string with hyphens replaced by spaces, e.g., :insert-into => INSERT INTO.

Any namespace qualifier is ignored.

Given a keyword, return a SQL representation of it as a string.

A `:kebab-case` keyword becomes a `KEBAB CASE` (uppercase) string
with hyphens replaced by spaces, e.g., `:insert-into` => `INSERT INTO`.

Any namespace qualifier is ignored.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close