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} :view a view or materialized view {:materialized?}; its columns follow, all nullable :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 (or an array of it) {:type-name :values :array?} :domain-ref column of a domain type (or an array of it) {:type-name :base (the type under its domains) :array?} :unknown-type type outside the mapping table (rendered as :any) {:type :type-schema (when not pg_catalog's or the schema's own)} :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} :exclude EXCLUDE constraint {:method :partial? :elements [{:column :op}]} :unique UNIQUE constraint {:columns :nulls-distinct? (false for NULLS NOT DISTINCT) :index? (from a unique index, not a constraint) :partial? (the index has a predicate)} :references FOREIGN KEY {:columns :match (:simple or :full) :to {:schema :table :columns} :valid? (false for NOT VALID)} :domain domain type {:type-name :base :not-null? :default :facts (column patterns over VALUE; :enum or :domain-ref for a base type of the schema) :value-type (what its CHECKs read VALUE as, pgmalli.impl.eval/column-type)} :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?} (also lower <= upper for a generated range column, named <column>_generated) :not-enforced a NOT ENFORCED CHECK or FOREIGN KEY {:constraint :input} (nothing to render) :trigger a row-level trigger left enabled {:name :before :insert :update :delete} (nothing to render) :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}
  :view         a view or materialized view          {:materialized?}; its columns follow, all nullable
  :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 (or an array of it) {:type-name :values :array?}
  :domain-ref   column of a domain type (or an array of it) {:type-name :base (the type under its domains) :array?}
  :unknown-type type outside the mapping table (rendered as :any) {:type :type-schema (when not pg_catalog's or the schema's own)}
  :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}
  :exclude      EXCLUDE constraint                     {:method :partial? :elements [{:column :op}]}
  :unique       UNIQUE constraint                      {:columns :nulls-distinct? (false for NULLS NOT DISTINCT)
                                                        :index? (from a unique index, not a constraint)
                                                        :partial? (the index has a predicate)}
  :references   FOREIGN KEY                            {:columns :match (:simple or :full) :to {:schema :table :columns} :valid? (false for NOT VALID)}
  :domain       domain type                            {:type-name :base :not-null? :default :facts (column patterns over VALUE;
                                                        :enum or :domain-ref for a base type of the schema)
                                                        :value-type (what its CHECKs read VALUE as, pgmalli.impl.eval/column-type)}
  :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?}
                (also lower <= upper for a generated range column, named <column>_generated)
  :not-enforced a NOT ENFORCED CHECK or FOREIGN KEY   {:constraint :input} (nothing to render)
  :trigger      a row-level trigger left enabled       {:name :before :insert :update :delete} (nothing to render)
  :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

column-patternsclj

(column-patterns e types)

The column patterns of an expression, every AND branch one, the columns as keywords; nil when a branch matches none. types as normalize reads it.

The column patterns of an expression, every AND branch one, the columns as keywords; nil
when a branch matches none. types as normalize reads it.
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