This is a low-level namespace implementing our query execution pipeline. Most of the stuff you'd use on a regular basis are implemented on top of stuff here.
This is a low-level namespace implementing our query execution pipeline. Most of the stuff you'd use on a regular basis are implemented on top of stuff here.
Thunk function to call every time a query is executed if toucan2.execute/with-call-count
is in use. Implementees
of transduce-compiled-query-with-connection
should invoke this every time a query gets executed. You can
use increment-call-count!
to simplify the chore of making sure it's non-nil
before invoking it.
Thunk function to call every time a query is executed if [[toucan2.execute/with-call-count]] is in use. Implementees of [[transduce-compiled-query-with-connection]] should invoke this every time a query gets executed. You can use [[increment-call-count!]] to simplify the chore of making sure it's non-`nil` before invoking it.
(base-query-type query-type)
E.g. something like :toucan.query-type/insert.*
. The immediate descendant of :toucan.query-type/*
.
(base-query-type :toucan.query-type/insert.instances)
=>
:toucan.query-type/insert.*
E.g. something like `:toucan.query-type/insert.*`. The immediate descendant of `:toucan.query-type/*`. ```clj (base-query-type :toucan.query-type/insert.instances) => :toucan.query-type/insert.* ```
(build query-type model parsed-args resolved-query)
Helper for getting a built query for a resolved-query
.
Helper for getting a built query for a `resolved-query`.
(query-type? query-type)
True if query-type
derives from one of the various abstract query keywords such as :toucan.result-type/*
or
:toucan.query-type/*
. This does not guarantee that the query type is a 'concrete', just that it is something with
some sort of query type information.
True if `query-type` derives from one of the various abstract query keywords such as `:toucan.result-type/*` or `:toucan.query-type/*`. This does not guarantee that the query type is a 'concrete', just that it is something with some sort of query type information.
(reducible-compiled-query-with-connection conn query-type model compiled-query)
(reducible-resolved-query query-type model parsed-args resolved-query)
(resolve-query query-type model unresolved-query)
Helper for getting the resolved query for unresolved-query
.
Helper for getting the resolved query for `unresolved-query`.
(similar-query-type-returning query-type result-type)
(similar-query-type-returning :toucan.query-type/insert.instances :toucan.result-type/pks)
=>
:toucan.query-type/insert.pks
```clj (similar-query-type-returning :toucan.query-type/insert.instances :toucan.result-type/pks) => :toucan.query-type/insert.pks ```
(transduce-built-query rf query-type₁ model₂ built-query₃)
The sixth step in the query execution pipeline. Called with a query that is ready to be compiled, e.g. a fully-formed Honey SQL form.
transduce-resolved-query
↓
(build query)
↓
transduce-built-query ← YOU ARE HERE
↓
toucan2.compile/with-compiled-query
↓
transduce-compiled-query
The default implementation compiles the query with toucan2.compile/with-compiled-query
and then
calls transduce-compiled-query
.
The sixth step in the query execution pipeline. Called with a query that is ready to be compiled, e.g. a fully-formed Honey SQL form. ``` transduce-resolved-query ↓ (build query) ↓ transduce-built-query ← YOU ARE HERE ↓ toucan2.compile/with-compiled-query ↓ transduce-compiled-query ``` The default implementation compiles the query with [[toucan2.compile/with-compiled-query]] and then calls [[transduce-compiled-query]].
(transduce-compiled-query rf query-type₁ model₂ compiled-query₃)
The seventh step in the query execution pipeline. Called with a compiled query that is ready to be executed natively, for
example a [sql & args]
vector, immediately before opening a connection.
transduce-built-query
↓
toucan2.compile/with-compiled-query
↓
transduce-compiled-query ← YOU ARE HERE
↓
toucan2.connection/with-connection
↓
transduce-compiled-query-with-connection
The default implementation opens a connection (or uses the current connection)
using toucan2.connection/with-connection
and then calls transduce-compiled-query-with-connection
.
The seventh step in the query execution pipeline. Called with a compiled query that is ready to be executed natively, for example a `[sql & args]` vector, immediately before opening a connection. ``` transduce-built-query ↓ toucan2.compile/with-compiled-query ↓ transduce-compiled-query ← YOU ARE HERE ↓ toucan2.connection/with-connection ↓ transduce-compiled-query-with-connection ``` The default implementation opens a connection (or uses the current connection) using [[toucan2.connection/with-connection]] and then calls [[transduce-compiled-query-with-connection]].
(transduce-compiled-query-with-connection rf
conn₁
query-type₂
model₃
compiled-query)
The eighth and final step in the query execution pipeline. Called with a fully compiled query that can be executed natively, and an open connection for executing it.
transduce-compiled-query
↓
toucan2.connection/with-connection
↓
transduce-compiled-query-with-connection ← YOU ARE HERE
↓
execute query
↓
transduce results
Implementations should execute the query and transduce the results using rf
. Implementations are database-specific,
which is why this method dispatches off of connection type (e.g. java.sql.Connection
). The default JDBC backend
executes the query and reduces results with toucan2.jdbc.query/reduce-jdbc-query
.
The eighth and final step in the query execution pipeline. Called with a fully compiled query that can be executed natively, and an open connection for executing it. ``` transduce-compiled-query ↓ toucan2.connection/with-connection ↓ transduce-compiled-query-with-connection ← YOU ARE HERE ↓ execute query ↓ transduce results ``` Implementations should execute the query and transduce the results using `rf`. Implementations are database-specific, which is why this method dispatches off of connection type (e.g. `java.sql.Connection`). The default JDBC backend executes the query and reduces results with [[toucan2.jdbc.query/reduce-jdbc-query]].
(transduce-parsed-args rf query-type₁ parsed-args)
The second step in the query execution pipeline. Called with args as parsed by something like
toucan2.query/parse-args
.
transduce-unparsed
↓
(parse args)
↓
transduce-parsed-args ← YOU ARE HERE
↓
toucan2.model/with-model
↓
transduce-with-model
The default implementation resolves the :modelable
in parsed-args
with toucan2.model/with-model
and then
calls transduce-with-model
.
The second step in the query execution pipeline. Called with args as parsed by something like [[toucan2.query/parse-args]]. ``` transduce-unparsed ↓ (parse args) ↓ transduce-parsed-args ← YOU ARE HERE ↓ toucan2.model/with-model ↓ transduce-with-model ``` The default implementation resolves the `:modelable` in `parsed-args` with [[toucan2.model/with-model]] and then calls [[transduce-with-model]].
(transduce-resolved-query rf query-type₁ model₂ parsed-args resolved-query₃)
The fifth step in the query execution pipeline. Called with a resolved query immediately before 'building' it.
transduce-unresolved-query
↓
(resolve query)
↓
transduce-resolved-query ← YOU ARE HERE
↓
(build query)
↓
transduce-built-query
The default implementation builds the resolved query and then calls transduce-built-query
.
The fifth step in the query execution pipeline. Called with a resolved query immediately before 'building' it. ``` transduce-unresolved-query ↓ (resolve query) ↓ transduce-resolved-query ← YOU ARE HERE ↓ (build query) ↓ transduce-built-query ``` The default implementation builds the resolved query and then calls [[transduce-built-query]].
(transduce-unparsed rf query-type₁ unparsed-args)
The first step in the query execution pipeline. Called with the unparsed args as passed to something
like toucan2.select/select
, before parsing the args.
Entrypoint e.g. select/select
↓
transduce-unparsed ← YOU ARE HERE
↓
(parse args)
↓
transduce-parsed-args
The default implementation parses the args with toucan2.query/parse-args
and then
calls transduce-parsed-args
.
The first step in the query execution pipeline. Called with the unparsed args as passed to something like [[toucan2.select/select]], before parsing the args. ``` Entrypoint e.g. select/select ↓ transduce-unparsed ← YOU ARE HERE ↓ (parse args) ↓ transduce-parsed-args ``` The default implementation parses the args with [[toucan2.query/parse-args]] and then calls [[transduce-parsed-args]].
(transduce-unresolved-query rf query-type₁ model₂ parsed-args unresolved-query₃)
The fourth step in the query execution pipeline.
transduce-with-model
↓
transduce-unresolved-query ← YOU ARE HERE
↓
(resolve query)
↓
transduce-resolved-query
The default implementation does nothing special with unresolved-query
, and passes it directly
to transduce-resolved-query
.
The fourth step in the query execution pipeline. ``` transduce-with-model ↓ transduce-unresolved-query ← YOU ARE HERE ↓ (resolve query) ↓ transduce-resolved-query ``` The default implementation does nothing special with `unresolved-query`, and passes it directly to [[transduce-resolved-query]].
(transduce-with-model rf query-type₁ model₂ parsed-args)
The third step in the query execution pipeline. This is the first step that dispatches off of resolved model.
transduce-parsed-args
↓
toucan2.model/with-model
↓
transduce-with-model ← YOU ARE HERE
↓
transduce-unresolved-query
The default implementation does nothing special and calls transduce-unresolved-query
with the :queryable
in
parsed-args
.
The third step in the query execution pipeline. This is the first step that dispatches off of resolved model. ``` transduce-parsed-args ↓ toucan2.model/with-model ↓ transduce-with-model ← YOU ARE HERE ↓ transduce-unresolved-query ``` The default implementation does nothing special and calls [[transduce-unresolved-query]] with the `:queryable` in `parsed-args`.
(with-init rf init)
Returns a version of reducing function rf
with a zero-arity (initial value arity) that returns init
.
Returns a version of reducing function `rf` with a zero-arity (initial value arity) that returns `init`.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close