Expand description
Column DEFAULT expression compilation and evaluation at insert time.
A declared DEFAULT is stored in the catalog as text. ColumnDefaults
compiles that text ONCE per statement; the per-row path evaluates the
compiled form and never sees a string, so it cannot re-parse.
Supported forms: ID generation functions (UUIDv4/v7, ULID, CUID2, NANOID),
NOW(), sequence accessors (nextval, currval), literals, and any other
expression the plan-time const-folder can resolve.
A DEFAULT that cannot be evaluated raises crate::SqlError::UnevaluableDefault.
The column is never omitted: an omitted column stores NULL where the
declaration promised a value, and nothing reports it.
Lives in the planner because every engine’s rows materialize their
DEFAULTs there, before declared-type coercion and range checks run, so a
materialized default is validated exactly like a supplied one and a
DEFAULT now() means the same thing on every engine.
Structs§
- Column
Defaults - Every declared DEFAULT of one collection, compiled once for a statement.
- Compiled
Default - One column DEFAULT, classified and parsed.
Functions§
- default_
value_ to_ sql - Convert an evaluated default back into the planner’s literal type.
- validate_
default_ expr - Check that
expr, the DEFAULT declared oncolumn, can be evaluated.