Liking cljdoc? Tell your friends :D

pgmalli.impl.pattern

Facts about a schema, derived from the structure read by pgmalli.impl.ir.

A fact is a map with :fact (the kind), :schema, and :table / :column / :constraint where they apply. CHECK constraints are matched against a fixed set of patterns (column patterns, then :branch-check and :or-check); anything else is kept as :table-check with the expression data, never dropped.

Kinds: :enum-type an enum type of the schema {:type-name :values} :column a column {:type :position :nullable? :default :identity :generated} :identity is :always, :default or :serial (a nextval default); :generated is the expression :enum column of an enum type {:type-name :values} :domain-ref column of a domain type {:type-name :base} :unknown-type type outside the mapping table (rendered as :any) {:type} :max-length varchar(n) {:max} :numeric numeric(p,s) {:precision :scale} :in-set col IN (...) / col = v {:values} :not-in-set col NOT IN (...) / col <> v {:values} :range col >= a AND col <= b, BETWEEN, ... {:min :max :min-exclusive? :max-exclusive?} :non-blank length(trim(col)) > 0 / col <> '' {:trim?} :length length(col) <= n, cardinality(col) > 0 {:fn :min :max :exact} :json-type jsonb_typeof(col) = 'object' {:json-type} :regex col ~ 're' {:re :case-insensitive?} :like col LIKE 'p' {:pattern :case-insensitive?} :not-null col IS NOT NULL :null col IS NULL :when-present col IS NULL OR <column pattern> {:fact-when-present} :primary-key table primary key {:columns} :unique UNIQUE constraint {:columns :nulls-distinct? (false for NULLS NOT DISTINCT)} :references FOREIGN KEY {:columns :match (:simple or :full) :to {:schema :table :columns}} :domain domain type {:type-name :base :not-null? :default :facts (column patterns over VALUE)} :domain-check CHECK of a domain that matched no pattern {:type-name :constraint :expr :valid?} :branch-check CHECK of the form col = v AND ... OR col = w AND ... {:dispatch :branches [{:values :facts} or {:null true :facts}] :default} :or-check CHECK whose OR alternatives are each an AND of column patterns {:alternatives [[fact ...] ...]} :table-check CHECK that matched no pattern {:expr :columns :valid?} :unparsed expression that could not be read {:input :error}

One CHECK can yield several facts (column patterns joined by AND); every fact from a CHECK carries the whole expression as :expr. NOT VALID constraints are never matched, since existing rows may violate them.

Facts about a schema, derived from the structure read by pgmalli.impl.ir.

A fact is a map with :fact (the kind), :schema, and :table / :column / :constraint where they
apply. CHECK constraints are matched against a fixed set of patterns (column patterns, then
:branch-check and :or-check); anything else is kept as :table-check with the expression data,
never dropped.

Kinds:
  :enum-type    an enum type of the schema           {:type-name :values}
  :column       a column                              {:type :position :nullable? :default :identity :generated}
                :identity is :always, :default or :serial (a nextval default); :generated is the expression
  :enum         column of an enum type                {:type-name :values}
  :domain-ref   column of a domain type               {:type-name :base}
  :unknown-type type outside the mapping table (rendered as :any) {:type}
  :max-length   varchar(n)                            {:max}
  :numeric      numeric(p,s)                          {:precision :scale}
  :in-set       col IN (...) / col = v                {:values}
  :not-in-set   col NOT IN (...) / col <> v            {:values}
  :range        col >= a AND col <= b, BETWEEN, ...   {:min :max :min-exclusive? :max-exclusive?}
  :non-blank    length(trim(col)) > 0 / col <> ''     {:trim?}
  :length       length(col) <= n, cardinality(col) > 0 {:fn :min :max :exact}
  :json-type    jsonb_typeof(col) = 'object'          {:json-type}
  :regex        col ~ 're'                            {:re :case-insensitive?}
  :like         col LIKE 'p'                          {:pattern :case-insensitive?}
  :not-null     col IS NOT NULL
  :null         col IS NULL
  :when-present col IS NULL OR <column pattern>       {:fact-when-present}
  :primary-key  table primary key                      {:columns}
  :unique       UNIQUE constraint                      {:columns :nulls-distinct? (false for NULLS NOT DISTINCT)}
  :references   FOREIGN KEY                            {:columns :match (:simple or :full) :to {:schema :table :columns}}
  :domain       domain type                            {:type-name :base :not-null? :default :facts (column patterns over VALUE)}
  :domain-check CHECK of a domain that matched no pattern {:type-name :constraint :expr :valid?}
  :branch-check CHECK of the form col = v AND ... OR col = w AND ...
                                                       {:dispatch :branches [{:values :facts} or {:null true :facts}] :default}
  :or-check     CHECK whose OR alternatives are each an AND of column patterns
                                                       {:alternatives [[fact ...] ...]}
  :table-check  CHECK that matched no pattern         {:expr :columns :valid?}
  :unparsed     expression that could not be read     {:input :error}

One CHECK can yield several facts (column patterns joined by AND); every fact from a CHECK
carries the whole expression as :expr. NOT VALID constraints are never matched, since
existing rows may violate them.
raw docstring

coverageclj

(coverage facts)

Counts per fact kind; :checks restricts to facts that came from CHECK constraints.

Counts per fact kind; :checks restricts to facts that came from CHECK constraints.
sourceraw docstring

factsclj

(facts schema)

Facts of one schema, ordered by type name, table name, column name and constraint name. Column positions are not used for ordering because they depend on migration order.

Facts of one schema, ordered by type name, table name, column name and constraint name.
Column positions are not used for ordering because they depend on migration order.
sourceraw docstring

referenced-columnsclj

(referenced-columns e)

Names of the columns an expression reads.

Names of the columns an expression reads.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close