Shared PostgreSQL row preparation and immediate constraint phases.
prepare-candidate materializes INSERT defaults and enforces NOT NULL.
validate-pre-arbiter! adds CHECK/domain validation before ON CONFLICT
arbitration. validate-mutation! validates an actual INSERT/UPDATE result
and therefore also enforces foreign keys. Keeping those phases distinct
mirrors PostgreSQL's ExecInsert/ExecOnConflictUpdate ordering.
Shared PostgreSQL row preparation and immediate constraint phases. `prepare-candidate` materializes INSERT defaults and enforces NOT NULL. `validate-pre-arbiter!` adds CHECK/domain validation before ON CONFLICT arbitration. `validate-mutation!` validates an actual INSERT/UPDATE result and therefore also enforces foreign keys. Keeping those phases distinct mirrors PostgreSQL's ExecInsert/ExecOnConflictUpdate ordering.
(compile-constraint-metadata {:keys [checks fks domain-enum] :as metadata})Compile a previously read metadata snapshot. Does not reread its database or evaluate defaults/predicates. Check ordering follows the input snapshot.
Compile a previously read metadata snapshot. Does not reread its database or evaluate defaults/predicates. Check ordering follows the input snapshot.
(constraint-metadata db table-name)Read per-table row-constraint inputs without parsing SQL expressions or evaluating defaults, predicates, or queries written in SQL. FK column JSON is decoded only to resolve the same physical attribute mappings as a plan. Retains raw definitions so changes can be compared before using a plan.
Read per-table row-constraint inputs without parsing SQL expressions or evaluating defaults, predicates, or queries written in SQL. FK column JSON is decoded only to resolve the same physical attribute mappings as a plan. Retains raw definitions so changes can be compared before using a plan.
(constraint-plan db table-name)Compile per-table metadata once for a statement/tx function.
Compile per-table metadata once for a statement/tx function.
(plan-required? plan explicit-nulls?)True when an INSERT needs the row-constraint transaction function.
A table's ordinary column list alone is not a reason to wrap every row. The wrapper is needed only for defaults/NOT NULL, row constraints, or to erase an explicit SQL NULL before handing the entity map to Datahike.
True when an INSERT needs the row-constraint transaction function. A table's ordinary column list alone is not a reason to wrap every row. The wrapper is needed only for defaults/NOT NULL, row constraints, or to erase an explicit SQL NULL before handing the entity map to Datahike.
(prepare-candidate attrs plan coerce-fn)Materialize omitted defaults and reject NULL in NOT NULL columns.
coerce-fn receives [value attr]. Sequence defaults must already have
been reserved through the live nextval service before row validation.
Materialize omitted defaults and reject NULL in NOT NULL columns. `coerce-fn` receives [value attr]. Sequence defaults must already have been reserved through the live nextval service before row validation.
(validate-mutation! db
table-name
attrs
plan
effective-rows
eval-check-fn
validate-domain-fn)Validate an actual INSERT/UPDATE result. Unlike a speculative candidate, this phase includes FK enforcement and never applies INSERT defaults.
Validate an actual INSERT/UPDATE result. Unlike a speculative candidate, this phase includes FK enforcement and never applies INSERT defaults.
(validate-pre-arbiter! db
table-name
attrs
plan
eval-check-fn
validate-domain-fn)Enforce constraints PostgreSQL checks before unique-index arbitration.
eval-check-fn receives [AST logical-row table-name schema].
validate-domain-fn, when supplied, receives the storage row.
Enforce constraints PostgreSQL checks before unique-index arbitration. `eval-check-fn` receives [AST logical-row table-name schema]. `validate-domain-fn`, when supplied, receives the storage row.
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 |