Utility functions for writing SQL drivers.
Utility functions for writing SQL drivers.
(quote-name driver identifier-type & components)
Inputs: [driver :- s/Keyword identifier-type :- hx/IdentifierType & components]
Quote unqualified string or keyword identifier(s) by passing them to hx/identifier
, then calling HoneySQL format
on the resulting Identifier
. Uses the sql.qp/quote-style
of the current driver. You can implement ->honeysql
for Identifier
if you need custom behavior here.
(quote-name :mysql "wow") ; -> "wow
"
(quote-name :h2 "wow") ; -> ""WOW""
You should only use this function for places where you are not using HoneySQL, such as queries written directly in
SQL. For HoneySQL forms, Identifier
is converted to SQL automatically when it is compiled.
Inputs: [driver :- s/Keyword identifier-type :- hx/IdentifierType & components] Quote unqualified string or keyword identifier(s) by passing them to `hx/identifier`, then calling HoneySQL `format` on the resulting `Identifier`. Uses the `sql.qp/quote-style` of the current driver. You can implement `->honeysql` for `Identifier` if you need custom behavior here. (quote-name :mysql "wow") ; -> "`wow`" (quote-name :h2 "wow") ; -> "\"WOW\"" You should only use this function for places where you are not using HoneySQL, such as queries written directly in SQL. For HoneySQL forms, `Identifier` is converted to SQL automatically when it is compiled.
(select-clause-alias-everything select-clause)
Make sure all the columns in select-clause
are alias forms, e.g. [:table.col :col]
instead of :table.col
.
(This faciliates our deduplication logic.)
Make sure all the columns in `select-clause` are alias forms, e.g. `[:table.col :col]` instead of `:table.col`. (This faciliates our deduplication logic.)
(select-clause-deduplicate-aliases select-clause)
Make sure every column in select-clause
has a unique alias. This is useful for databases like Oracle that can't
figure out how to use a query that produces duplicate columns in a subselect.
Make sure every column in `select-clause` has a unique alias. This is useful for databases like Oracle that can't figure out how to use a query that produces duplicate columns in a subselect.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close