Some utility functions for building SQL strings.
These were originally private functions in next.jdbc.sql
but
they may proof 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 proof useful to developers who want to write their own 'SQL sugar' functions, such as a database-specific `upsert!` etc.
(as-? key-map opts)
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.
(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.
(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.
(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.
(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.
(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 :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 `:suffix` is provided in `opts`, that string is appended to the `INSERT ...` statement.
(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.
(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`.
(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.
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. If `:suffix` is provided in `opts`, that string is appended to the `SELECT ...` statement.
(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.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close