HugSQL adapter for PG2. Hacks, hacks, hacks.
HugSQL adapter for PG2. Hacks, hacks, hacks.
(def-db-fns file)
(def-db-fns file defaults)
(def-db-fns file defaults options)
Read and inject functions from a .sql file.
Acts like hugsql.core/def-db-fns
but overrides
some internal steps.
It automatically creates a PG2-related adapter and assigns it to the newly created functions.
Arguments:
file
is either a string, or a resource, or a file
object which is the source of a .sql payload;
defaults
is a map of arguments what will be passed
to pg.core/execute
on each call. See the PG2 readme file
for more details;
options
is map of HugSQL options. It's unlikely you
will need to use it.
Once this function is called, functions from the .sql file appear in the current namespace. Each function has the following signature:
[db] [db params] [db params opt], where:
db
is either a connection config map, or a connection,
or a pool. If it was config map, the connection gets closed
afterwards. When it's a pool, the connection is borrowed from
it and then returned;
params
is the standard HugSQL map of SQL parameters;
opt
: pg2-specific arguments that are passed to the
pg.core/execute
function. They will override the defaults
passed to the def-db-fns
call.
Read and inject functions from a .sql file. Acts like `hugsql.core/def-db-fns` but overrides some internal steps. It automatically creates a PG2-related adapter and assigns it to the newly created functions. Arguments: - `file` is either a string, or a resource, or a file object which is the source of a .sql payload; - `defaults` is a map of arguments what will be passed to `pg.core/execute` on each call. See the PG2 readme file for more details; - `options` is map of HugSQL options. It's unlikely you will need to use it. Once this function is called, functions from the .sql file appear in the current namespace. Each function has the following signature: [db] [db params] [db params opt], where: - `db` is either a connection config map, or a connection, or a pool. If it was config map, the connection gets closed afterwards. When it's a pool, the connection is borrowed from it and then returned; - `params` is the standard HugSQL map of SQL parameters; - `opt`: pg2-specific arguments that are passed to the `pg.core/execute` function. They will override the defaults passed to the `def-db-fns` call.
(def-sqlvec-fns file)
(def-sqlvec-fns file options)
Read and inject sqlvec-functions from a .sql file. These functions don't interact with a database but produce pure SQL vectors. Useful for debugging SQL you wrote, and for unit tests.
Acts like hugsql.core/def-db-fns
but with some
internal steps.
file
is either a string, or a resource, or a file
object which is the source of a .sql payload;
options
is a map of hugsql parameters. The most
interesting is :fn-suffix
to override the default
'-sqlvec' ending with something else.
Read and inject sqlvec-functions from a .sql file. These functions don't interact with a database but produce pure SQL vectors. Useful for debugging SQL you wrote, and for unit tests. Acts like `hugsql.core/def-db-fns` but with some internal steps. - `file` is either a string, or a resource, or a file object which is the source of a .sql payload; - `options` is a map of hugsql parameters. The most interesting is `:fn-suffix` to override the default '-sqlvec' ending with something else.
(intern-function fn-name fn-meta fn-obj)
Inject a function produced by HugSQL into the current namespace.
Inject a function produced by HugSQL into the current namespace.
(intern-sqlvec-function fn-name fn-meta fn-obj)
Inject a sqlvec function produced by HugSQL into the current namespace.
Inject a sqlvec function produced by HugSQL into the current namespace.
(make-adapter)
(make-adapter defaults)
Initiate an adapter object. The defaults, when specified,
are passed to the pg.core/execute
function.
Initiate an adapter object. The defaults, when specified, are passed to the `pg.core/execute` function.
(remap-$-params sql)
Replace all parameter stubs with $1, $2, etc.
Replace all parameter stubs with $1, $2, etc.
(wrap-$-params -f)
Post-correct SQL vector: replace PaRaM figures with dollar parameters.
Post-correct SQL vector: replace __PaRaM__ figures with dollar parameters.
(wrap-signature -f)
Slightly correct the signature of a function
produced by HugSQL. Namely, pass pg.core/execute
parameters through a dedicated key to prevent
merging them with something else.
Slightly correct the signature of a function produced by HugSQL. Namely, pass `pg.core/execute` parameters through a dedicated key to prevent merging them with something else.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close