HoneySQL query data checked against a registry, without a database: the tables must exist, the columns a query selects, returns, inserts, sets or compares must exist, an INSERT must carry the required columns, an enum literal must be one of the enum's values; and from the same data, the types of the query's parameters and of the rows it returns, as malli schemas.
Scope: tables come from :from, :using, the joins, :insert-into, :update and :delete-from, under their aliases. CTEs (:with), subqueries and table functions are opaque tables: their columns exist but have no type. A column is :col (unique in the scope), :alias/col or :alias.col; a column a subquery cannot resolve is looked for in the enclosing statements, as PostgreSQL does. An unqualified table is in :schema (default "public").
Types are data malli's default registry reads (see pgmalli.core/portable). Date and timestamp columns are inst? by default; :time :instant or :local gives the malli.experimental.time types, as as-read does.
HoneySQL query data checked against a registry, without a database: the tables must exist, the columns a query selects, returns, inserts, sets or compares must exist, an INSERT must carry the required columns, an enum literal must be one of the enum's values; and from the same data, the types of the query's parameters and of the rows it returns, as malli schemas. Scope: tables come from :from, :using, the joins, :insert-into, :update and :delete-from, under their aliases. CTEs (:with), subqueries and table functions are opaque tables: their columns exist but have no type. A column is :col (unique in the scope), :alias/col or :alias.col; a column a subquery cannot resolve is looked for in the enclosing statements, as PostgreSQL does. An unqualified table is in :schema (default "public"). Types are data malli's default registry reads (see pgmalli.core/portable). Date and timestamp columns are inst? by default; :time :instant or :local gives the malli.experimental.time types, as as-read does.
(arg-types registry body)(arg-types registry body {:keys [schema] :or {schema "public"} :as opts}){symbol schema} for the symbols of a query: a symbol compared with a column has the column's type (:in a :sequential of it), one assigned to it the column's type with NULL, one in :limit / :offset :int. The first typed use wins; a use that gives no type (:any) never hides one that does.
{symbol schema} for the symbols of a query: a symbol compared with a column has the
column's type (:in a :sequential of it), one assigned to it the column's type with NULL,
one in :limit / :offset :int. The first typed use wins; a use that gives no type (:any)
never hides one that does.(check registry body)(check registry body opts)The problems of every statement of a query. A query whose :with is built elsewhere (not data) cannot have its unknown tables judged, so those are left out for it.
The problems of every statement of a query. A query whose :with is built elsewhere (not data) cannot have its unknown tables judged, so those are left out for it.
(cte-names body)Names of the CTEs a query defines, at any depth.
Names of the CTEs a query defines, at any depth.
(problems registry stmt scope {:keys [schema] :or {schema "public"}})The problems of one statement: unknown tables; columns selected, returned, inserted, set or compared that are unknown, or ambiguous (unqualified and in more than one table in scope); required INSERT columns missing; enum literals outside the enum (compared with, or assigned to, the column). scope is the statement's (from scope) or, for a nested statement, the chain of its own and the enclosing ones. Empty when the statement agrees with the registry.
The problems of one statement: unknown tables; columns selected, returned, inserted, set or compared that are unknown, or ambiguous (unqualified and in more than one table in scope); required INSERT columns missing; enum literals outside the enum (compared with, or assigned to, the column). scope is the statement's (from scope) or, for a nested statement, the chain of its own and the enclosing ones. Empty when the statement agrees with the registry.
(query-schema registry args body)(query-schema registry args body opts)[:=> [:cat arg-types...] [:sequential row]] for a function taking args and running body: a malli function schema for instrumentation. A return that cannot be resolved is :any.
[:=> [:cat arg-types...] [:sequential row]] for a function taking args and running body: a malli function schema for instrumentation. A return that cannot be resolved is :any.
(resolve-column registry scope col){:table :column :schema} for a column keyword in a scope (or the chain of scopes of a nested statement), :table the alias for an opaque table and :schema nil there; nil when the column resolves to no table or to several.
{:table :column :schema} for a column keyword in a scope (or the chain of scopes of a
nested statement), :table the alias for an opaque table and :schema nil there; nil when
the column resolves to no table or to several.(row-schema registry stmt ctes)(row-schema registry stmt ctes {:keys [qualified? kebab? nil-columns] :as opts})The [:map ...] of one row a statement returns, as the driver builds it (as-read's :qualified?, :kebab?, :nil-columns and :time; an opaque source's columns under its alias) and as malli's default registry reads it; an expression under an alias is nullable :any; :* and :t/* are the columns of the tables. nil when a selected column cannot be resolved.
The [:map ...] of one row a statement returns, as the driver builds it (as-read's :qualified?, :kebab?, :nil-columns and :time; an opaque source's columns under its alias) and as malli's default registry reads it; an expression under an alias is nullable :any; :* and :t/* are the columns of the tables. nil when a selected column cannot be resolved.
(scope registry stmt ctes {:keys [schema] :or {schema "public"}}){alias {:table "schema.table" :opaque? bool :cte? bool}} of one statement; ctes are the query's CTE names, which shadow a table only when the reference is written without a schema.
{alias {:table "schema.table" :opaque? bool :cte? bool}} of one statement; ctes are the
query's CTE names, which shadow a table only when the reference is written without a schema.(statements body)The statements in a query (a map, or Clojure data holding maps); a subquery is one too.
The statements in a query (a map, or Clojure data holding maps); a subquery is one too.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |