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.
(*transduce-compiled-query-with-connection* rf
conn
query-type
model
compiled-query)
(*transduce-resolved-query* rf query-type model parsed-args resolved-query)
(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.* ```
(define-out-transform [query-type model-type] [instance-binding] & body)
(reducible-compiled-query-with-connection conn query-type model compiled-query)
(reducible-resolved-query query-type model parsed-args resolved-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 fifth 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*
↓
toucan2.query/with-built-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 fifth 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* ↓ toucan2.query/with-built-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 sixth 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 sixth 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)
(transduce-compiled-query-with-connection* rf
conn₁
query-type₂
model₃
compiled-query)
The seventh 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 seventh 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 toucan2.query/parse-args
.
transduce-unparsed*
↓
toucan2.query/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 [[toucan2.query/parse-args]]. ``` transduce-unparsed* ↓ toucan2.query/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)
(transduce-resolved-query* rf query-type₁ model₂ parsed-args resolved-query₃)
The fourth step in the query execution pipeline. Called with a resolved query immediately before 'building' it.
transduce-with-model*
↓
toucan2.query/with-resolved-query
↓
transduce-resolved-query* ← YOU ARE HERE
↓
toucan2.query/with-built-query
↓
transduce-built-query*
The default implementation builds the resolved query with toucan2.query/with-built-query
and then
calls transduce-built-query*
.
The fourth step in the query execution pipeline. Called with a resolved query immediately before 'building' it. ``` transduce-with-model* ↓ toucan2.query/with-resolved-query ↓ transduce-resolved-query* ← YOU ARE HERE ↓ toucan2.query/with-built-query ↓ transduce-built-query* ``` The default implementation builds the resolved query with [[toucan2.query/with-built-query]] and then calls [[transduce-built-query*]].
(transduce-unparsed query-type unparsed)
(transduce-unparsed rf query-type unparsed)
(transduce-unparsed* rf query-type₁ unparsed)
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
↓
toucan2.query/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 ↓ toucan2.query/parse-args ↓ transduce-parsed-args* ``` The default implementation parses the args with [[toucan2.query/parse-args]] and then calls [[transduce-parsed-args*]].
(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
↓
toucan2.query/with-resolved-query
↓
transduce-resolved-query*
The default implementation resolves the queryable with toucan2.query/with-resolved-query
and then
calls transduce-resolved-query*
.
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 ↓ toucan2.query/with-resolved-query ↓ transduce-resolved-query* ``` The default implementation resolves the queryable with [[toucan2.query/with-resolved-query]] and then calls [[transduce-resolved-query*]].
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close