Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

E0025 insert-without-columns

INSERT without a column list.

CodeNameCategoryDefault
E0025insert-without-columnsrestrictionoff

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.