Liking cljdoc? Tell your friends :D

toucan2.query


apply-kv-argclj

(apply-kv-arg model₁ resolved-query₂ k₃ v)

Merge a key-value pair into a query, presumably a map. What this means depends on the [[toucan2.protocols/dispatch-value]] of query -- for a plain map, the default Honey SQL backend applies k and v as a :where condition:

(apply-kv-arg :default {} :k :v)
;; =>
{:where [:= :k :v]}

You can add new implementations of this method to special behaviors for support arbitrary keys, or to support new query backends. :toucan/pk support is implemented this way.

apply-kv-arg is defined in toucan2.query (toucan2/query.clj:124).

It caches methods using a methodical.impl.cache.watching.WatchingCache.

It uses the method combination methodical.impl.combo.threaded.ThreadingMethodCombination with the threading strategy :thread-last.

It uses the dispatcher methodical.impl.dispatcher.multi_default.MultiDefaultDispatcher with hierarchy #'clojure.core/global-hierarchy and prefs {}.

The default value is :default.

It uses the method table methodical.impl.method_table.standard.StandardMethodTable.

These primary methods are known:

  • [:default clojure.lang.IPersistentMap :default], defined in toucan2.honeysql2 (toucan2/honeysql2.clj:44)

    It has the following documentation:

    Apply key-value args to a Honey SQL 2 query map.

These aux methods are known:

:around methods:

  • [:default :default :toucan/pk], defined in toucan2.query (toucan2/query.clj:202)

    It has the following documentation:

    Implementation for handling key-value args for :toucan/pk.

    This is an :around so we can intercept the normal handler. This 'unpacks' the PK and ultimately uses the normal calls to apply-kv-arg.

Merge a key-value pair into a `query`, presumably a map. What this means depends on
  the [[toucan2.protocols/dispatch-value]] of `query` -- for a plain map, the default Honey SQL backend applies `k` and
  `v` as a `:where` condition:

  ```clj
  (apply-kv-arg :default {} :k :v)
  ;; =>
  {:where [:= :k :v]}
  ```

  You can add new implementations of this method to special behaviors for support arbitrary keys, or to support new
  query backends. `:toucan/pk` support is implemented this way.

apply-kv-arg is defined in [[toucan2.query]] (toucan2/query.clj:124).

It caches methods using a `methodical.impl.cache.watching.WatchingCache`.

It uses the method combination `methodical.impl.combo.threaded.ThreadingMethodCombination`
with the threading strategy `:thread-last`.

It uses the dispatcher `methodical.impl.dispatcher.multi_default.MultiDefaultDispatcher`
with hierarchy `#'clojure.core/global-hierarchy`
and prefs `{}`.

The default value is `:default`.

It uses the method table `methodical.impl.method_table.standard.StandardMethodTable`.

These primary methods are known:

* `[:default clojure.lang.IPersistentMap :default]`, defined in [[toucan2.honeysql2]] (toucan2/honeysql2.clj:44) 
  
  It has the following documentation:
  
  Apply key-value args to a Honey SQL 2 query map.

These aux methods are known:

`:around` methods:

* `[:default :default :toucan/pk]`, defined in [[toucan2.query]] (toucan2/query.clj:202) 
  
  It has the following documentation:
  
  Implementation for handling key-value args for `:toucan/pk`.
  
    This is an `:around` so we can intercept the normal handler. This 'unpacks' the PK and ultimately uses the normal
    calls to [[apply-kv-arg]].
sourceraw docstring

apply-kv-argsclj

(apply-kv-args model query kv-args)

Convenience. Merge a map of kv-args into a resolved query with repeated calls to apply-kv-arg.

Convenience. Merge a map of `kv-args` into a resolved `query` with repeated calls to [[apply-kv-arg]].
sourceraw docstring

parse-argsclj

(parse-args query-type₁ unparsed-args)

parse-args takes a sequence of unparsed args passed to something like toucan2.select/select and parses them into a parsed args map. The default implementation uses [[clojure.spec.alpha]] to parse the args according to args-spec.

These keys are commonly returned by several of the different implementations parse-args, and other tooling is build to leverage them:

  • :modelable -- usually the first of the unparsed-args, this is the thing that should get resolved to a model with toucan2.model/resolve-model.

  • :queryable -- something that can be resolved to a query, for example a map or integer or 'named query' keyword. The resolved query is ultimately combined with other parsed args and built into something like a Honey SQL map, then compiled to something like SQL.

  • :kv-args -- map of key-value pairs. When [[build]] builds a query, it calls apply-kv-arg for each of the key-value pairs. The default behavior is to append a Honey SQL :where clause based on the pair; but you can customize the behavior for specific keywords to do other things -- :toucan/pk is one such example.

  • :columns -- for things that return instances, :columns is a sequence of columns to return. These are commonly specified by wrapping the modelable in a [modelable & columns] vector.

parse-args is defined in toucan2.query (toucan2/query.clj:91).

It caches methods using a methodical.impl.cache.watching.WatchingCache.

It uses the method combination methodical.impl.combo.threaded.ThreadingMethodCombination with the threading strategy :thread-last.

It uses the dispatcher methodical.impl.dispatcher.multi_default.MultiDefaultDispatcher with hierarchy #'clojure.core/global-hierarchy and prefs {}.

The default value is :default.

It uses the method table methodical.impl.method_table.standard.StandardMethodTable.

These primary methods are known:

  • :default, defined in toucan2.query (toucan2/query.clj:116)

    It has the following documentation:

    The default implementation calls parse-args-with-spec with the :toucan2.query/default-args spec.

  • :toucan.query-type/insert.*, defined in toucan2.insert (toucan2/insert.clj:32)

    It has the following documentation:

    Default args parsing method for toucan2.insert/insert!. Uses the spec :toucan2.insert/args.

  • :toucan.query-type/update.*, defined in toucan2.update (toucan2/update.clj:24)

`parse-args` takes a sequence of unparsed args passed to something like [[toucan2.select/select]] and parses them into
  a parsed args map. The default implementation uses [[clojure.spec.alpha]] to parse the args according to `args-spec`.

  These keys are commonly returned by several of the different implementations `parse-args`, and other tooling is
  build to leverage them:

  * `:modelable` -- usually the first of the `unparsed-args`, this is the thing that should get resolved to a model
     with [[toucan2.model/resolve-model]].

  * `:queryable` -- something that can be resolved to a query, for example a map or integer or 'named query' keyword.
    The resolved query is ultimately combined with other parsed args and built into something like a Honey SQL map, then
    compiled to something like SQL.

  * `:kv-args` -- map of key-value pairs. When [[build]] builds a query, it calls [[apply-kv-arg]] for each of the
    key-value pairs. The default behavior is to append a Honey SQL `:where` clause based on the pair; but you can
    customize the behavior for specific keywords to do other things -- `:toucan/pk` is one such example.

  * `:columns` -- for things that return instances, `:columns` is a sequence of columns to return. These are commonly
    specified by wrapping the modelable in a `[modelable & columns]` vector.

parse-args is defined in [[toucan2.query]] (toucan2/query.clj:91).

It caches methods using a `methodical.impl.cache.watching.WatchingCache`.

It uses the method combination `methodical.impl.combo.threaded.ThreadingMethodCombination`
with the threading strategy `:thread-last`.

It uses the dispatcher `methodical.impl.dispatcher.multi_default.MultiDefaultDispatcher`
with hierarchy `#'clojure.core/global-hierarchy`
and prefs `{}`.

The default value is `:default`.

It uses the method table `methodical.impl.method_table.standard.StandardMethodTable`.

These primary methods are known:

* `:default`, defined in [[toucan2.query]] (toucan2/query.clj:116) 
  
  It has the following documentation:
  
  The default implementation calls [[parse-args-with-spec]] with the `:toucan2.query/default-args` spec.

* `:toucan.query-type/insert.*`, defined in [[toucan2.insert]] (toucan2/insert.clj:32) 
  
  It has the following documentation:
  
  Default args parsing method for [[toucan2.insert/insert!]]. Uses the spec `:toucan2.insert/args`.

* `:toucan.query-type/update.*`, defined in [[toucan2.update]] (toucan2/update.clj:24) 
sourceraw docstring

parse-args-with-specclj

(parse-args-with-spec query-type spec unparsed-args)

Parse unparsed-args for query-type with the given spec. See documentation for parse-args for more details.

Parse `unparsed-args` for `query-type` with the given `spec`. See documentation for [[parse-args]] for more details.
sourceraw docstring

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

× close