Defaults for Omitted Column Values
A column default supplies a value under the database's insertion rules when the caller requests a default or omits that column.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace a created record
A new draft can use status draft when the insert leaves status omitted. Explicitly specifying null is a different assignment and may fail another constraint. Optional fields explain the same omission distinction in input records.
Verify explicit values
Test create with an omitted status, with an allowed explicit status, and with unsupported null under the database contract. See required values.[1][2]
Compare omission, explicit value and explicit null
A new record can default status to draft when an insert omits the column. An explicit approved value can override that default where the model permits it. Supplying null generally asks to store null, subject to constraints. See required and optional data fields.
Omit status → use default draft
Supply approved → store approved if permitted
Supply null → absence or constraint failure
Check what happens to rows already stored
Changing a default for future writes does not by itself define the interpretation of all old data. Verify how a schema migration handles existing rows under the chosen database. Test explicit zero for numeric defaults.