Liking cljdoc? Tell your friends :D

next.jdbc.sql.builder

Some utility functions for building SQL strings.

These were originally private functions in next.jdbc.sql but they may prove useful to developers who want to write their own 'SQL sugar' functions, such as a database-specific upsert! etc.

Some utility functions for building SQL strings.

These were originally private functions in `next.jdbc.sql` but
they may prove useful to developers who want to write their own
'SQL sugar' functions, such as a database-specific `upsert!` etc.
raw docstring

as-?clj

(as-? key-map _)

Given a hash map of column names and values, or a vector of column names, return a string of ? placeholders for them.

Given a hash map of column names and values, or a vector of column names,
return a string of `?` placeholders for them.
sourceraw docstring

as-colsclj

(as-cols cols opts)

Given a sequence of raw column names, return a string of all the formatted column names.

If a raw column name is a keyword, apply :column-fn to its name, from the options if present.

If a raw column name is a vector pair, treat it as an expression with an alias. If the first item is a keyword, apply :column-fn to its name, else accept it as-is. The second item should be a keyword and that will have :column-fn applied to its name.

This allows columns to be specified as simple names, e.g., :foo, as simple aliases, e.g., [:foo :bar], or as expressions with an alias, e.g., ["count(*)" :total].

Given a sequence of raw column names, return a string of all the
formatted column names.

If a raw column name is a keyword, apply `:column-fn` to its name,
from the options if present.

If a raw column name is a vector pair, treat it as an expression with
an alias. If the first item is a keyword, apply `:column-fn` to its
name, else accept it as-is. The second item should be a keyword and
that will have `:column-fn` applied to its name.

This allows columns to be specified as simple names, e.g., `:foo`,
as simple aliases, e.g., `[:foo :bar]`, or as expressions with an
alias, e.g., `["count(*)" :total]`.
sourceraw docstring

as-keysclj

(as-keys key-map opts)

Given a hash map of column names and values, return a string of all the column names.

Applies any :column-fn supplied in the options.

Given a hash map of column names and values, return a string of all the
column names.

Applies any `:column-fn` supplied in the options.
sourceraw docstring

by-keysclj

(by-keys key-map clause opts)

Given a hash map of column names and values and a clause type (:set, :where), return a vector of a SQL clause and its parameters.

Applies any :column-fn supplied in the options.

Given a hash map of column names and values and a clause type
(`:set`, `:where`), return a vector of a SQL clause and its parameters.

Applies any `:column-fn` supplied in the options.
sourceraw docstring

for-deleteclj

(for-delete table where-params opts)

Given a table name and either a hash map of column names and values or a vector of SQL (where clause) and its parameters, return a vector of the full DELETE SQL string and its parameters.

Applies any :table-fn / :column-fn supplied in the options.

If :suffix is provided in opts, that string is appended to the DELETE ... statement.

Given a table name and either a hash map of column names and values or a
vector of SQL (where clause) and its parameters, return a vector of the
full `DELETE` SQL string and its parameters.

Applies any `:table-fn` / `:column-fn` supplied in the options.

If `:suffix` is provided in `opts`, that string is appended to the
`DELETE ...` statement.
sourceraw docstring

for-insertclj

(for-insert table key-map opts)

Given a table name and a hash map of column names and their values, return a vector of the full INSERT SQL string and its parameters.

Applies any :table-fn / :column-fn supplied in the options.

If :suffix is provided in opts, that string is appended to the INSERT ... statement.

Given a table name and a hash map of column names and their values,
return a vector of the full `INSERT` SQL string and its parameters.

Applies any `:table-fn` / `:column-fn` supplied in the options.

If `:suffix` is provided in `opts`, that string is appended to the
`INSERT ...` statement.
sourceraw docstring

for-insert-multiclj

(for-insert-multi table cols rows opts)

Given a table name, a vector of column names, and a vector of row values (each row is a vector of its values), return a vector of the full INSERT SQL string and its parameters.

Applies any :table-fn / :column-fn supplied in the options.

If :batch is set to true in opts the INSERT statement will be prepared using a single set of placeholders and remaining parameters in the vector will be grouped at the row level.

If :suffix is provided in opts, that string is appended to the INSERT ... statement.

Given a table name, a vector of column names, and a vector of row values
(each row is a vector of its values), return a vector of the full `INSERT`
SQL string and its parameters.

Applies any `:table-fn` / `:column-fn` supplied in the options.

If `:batch` is set to `true` in `opts` the INSERT statement will be prepared
using a single set of placeholders and remaining parameters in the vector will
be grouped at the row level.

If `:suffix` is provided in `opts`, that string is appended to the
`INSERT ...` statement.
sourceraw docstring

for-orderclj

(for-order order-by opts)

Given an :order-by vector, return an ORDER BY clause.

Given an `:order-by` vector, return an `ORDER BY` clause.
sourceraw docstring

for-order-colclj

(for-order-col col opts)

Given a column name, or a pair of column name and direction, return the sub-clause for addition to ORDER BY.

Given a column name, or a pair of column name and direction,
return the sub-clause for addition to `ORDER BY`.
sourceraw docstring

for-queryclj

(for-query table where-params opts)

Given a table name and either a hash map of column names and values or a vector of SQL (where clause) and its parameters, return a vector of the full SELECT SQL string and its parameters.

Applies any :table-fn / :column-fn supplied in the options.

Handles pagination options (:top, :limit / :offset, or :offset / :fetch) for SQL Server, MySQL / SQLite, ANSI SQL respectively.

By default, this selects all columns, but if the :columns option is present the select will only be those columns.

If :suffix is provided in opts, that string is appended to the SELECT ... statement.

Given a table name and either a hash map of column names and values or a
vector of SQL (where clause) and its parameters, return a vector of the
full `SELECT` SQL string and its parameters.

Applies any `:table-fn` / `:column-fn` supplied in the options.

Handles pagination options (`:top`, `:limit` / `:offset`, or `:offset` /
`:fetch`) for SQL Server, MySQL / SQLite, ANSI SQL respectively.

By default, this selects all columns, but if the `:columns` option is
present the select will only be those columns.

If `:suffix` is provided in `opts`, that string is appended to the
`SELECT ...` statement.
sourceraw docstring

for-updateclj

(for-update table key-map where-params opts)

Given a table name, a vector of column names to set and their values, and either a hash map of column names and values or a vector of SQL (where clause) and its parameters, return a vector of the full UPDATE SQL string and its parameters.

Applies any :table-fn / :column-fn supplied in the options.

If :suffix is provided in opts, that string is appended to the UPDATE ... statement.

Given a table name, a vector of column names to set and their values, and
either a hash map of column names and values or a vector of SQL (where clause)
and its parameters, return a vector of the full `UPDATE` SQL string and its
parameters.

Applies any `:table-fn` / `:column-fn` supplied in the options.

If `:suffix` is provided in `opts`, that string is appended to the
`UPDATE ...` statement.
sourceraw docstring

qualified-nameclj

(qualified-name k)

Like clojure.core/name but preserves the qualifier, if any.

Intended for use with :name-fn, instead of the default name.

Like `clojure.core/name` but preserves the qualifier, if any.

Intended for use with `:name-fn`, instead of the default `name`.
sourceraw docstring

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

× close