E0025 insert-without-columns
INSERT without a column list.
| Code | Name | Category | Default |
|---|---|---|---|
E0025 | insert-without-columns | restriction | off |
What it reports
INSERT INTO t VALUES (...) or INSERT INTO t SELECT ... without a column list assigns values by the position of the table's columns. When a column is added, the statement fails, or worse, silently puts values in the wrong columns.
Example
INSERT INTO users VALUES (DEFAULT, 'Ann', 'ann@example.com', now());
warning[E0025]: INSERT without a column list depends on the order of the table's columns
--> q.sql:1:13
|
1 | INSERT INTO users VALUES (DEFAULT, 'Ann', 'ann@example.com', now());
| ^^^^^
= help: List the target columns: INSERT INTO t (a, b) ...
Fixed:
INSERT INTO users (name, email) VALUES ('Ann', 'ann@example.com');
Notes
INSERT INTO t DEFAULT VALUES is not reported.
Configuring
This rule is off by default. To enable it:
# sqlsift.toml
[rules]
insert-without-columns = "warn" # or "error"
Or on the command line: -W insert-without-columns, or -W restriction for every restriction rule. The examples use the schema on the Rules page.