Liking cljdoc? Tell your friends :D

toucan2.pipeline

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.
raw docstring

*call-count-thunk*clj

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.
sourceraw docstring

base-query-typeclj

(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.*
```
sourceraw docstring

buildclj

(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`.
sourceraw docstring

default-rfclj

(default-rf query-type)
source

do-traced-pipelineclj

(do-traced-pipeline thunk)
source

first-result-rfclj

(first-result-rf rf)
source

increment-call-count!clj

(increment-call-count!)
source

parent-query-typeclj

(parent-query-type query-type)
source

query-type?clj

(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.
sourceraw docstring

reducible-built-queryclj

(reducible-built-query query-type model built-query)
source

reducible-compiled-queryclj

(reducible-compiled-query query-type model compiled-query)
source

reducible-compiled-query-with-connectionclj

(reducible-compiled-query-with-connection conn query-type model compiled-query)
source

reducible-parsed-argsclj

(reducible-parsed-args query-type parsed-args)
source

reducible-resolved-queryclj

(reducible-resolved-query query-type model parsed-args resolved-query)
source

reducible-unparsedclj

(reducible-unparsed query-type unparsed)
source

reducible-with-modelclj

(reducible-with-model query-type model parsed-args)
source

resolve-queryclj

(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`.
sourceraw docstring

similar-query-type-returningclj

(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
```
sourceraw docstring

transduce-built-queryclj

(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]].
sourceraw docstring

transduce-compiled-queryclj

(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]].
sourceraw docstring

transduce-compiled-query-with-connectionclj

(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]].
sourceraw docstring

transduce-parsed-argsclj

(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]].
sourceraw docstring

transduce-resolved-queryclj

(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]].
sourceraw docstring

transduce-unparsedclj

(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]].
sourceraw docstring

transduce-unparsed-first-resultclj

(transduce-unparsed-first-result query-type unparsed)
source

transduce-unparsed-with-default-rfclj

(transduce-unparsed-with-default-rf query-type unparsed)
source

transduce-unresolved-queryclj

(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]].
sourceraw docstring

transduce-with-modelclj

(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`.
sourceraw docstring

with-initclj

(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`.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close