E0008 missing-required-column
INSERT omits a NOT NULL column without a default.
| Code | Name | Category | Default |
|---|---|---|---|
E0008 | missing-required-column | correctness | error |
What it reports
An INSERT with a column list leaves out a column that is NOT NULL and has no default, so the database would reject the row. Columns with a DEFAULT, identity columns, generated columns, SERIAL and AUTO_INCREMENT columns may be omitted.
Example
INSERT INTO users (name) VALUES ('Alice');
error[E0008]: INSERT into 'users' is missing required column 'email'
--> q.sql:1:13
|
1 | INSERT INTO users (name) VALUES ('Alice');
| ^^^^^
= help: 'email' is NOT NULL without a default. Provide a value, or add a DEFAULT to the schema
Fixed:
INSERT INTO users (name, email) VALUES ('Alice', 'alice@example.com');
Notes
Tables with a BEFORE INSERT (or INSTEAD OF INSERT) trigger in the schema are not checked: the trigger may fill the column. If something else fills it in a way sqlsift can't see, set this rule to warn or off.
Configuring
# sqlsift.toml
[rules]
missing-required-column = "warn" # or "off"
Or for a single line: -- sqlsift:disable E0008. The examples use the schema on the Rules page.