E0002 column-not-found
Referenced column does not exist in table.
| Code | Name | Category | Default |
|---|---|---|---|
E0002 | column-not-found | correctness | error |
What it reports
A column reference doesn't match any column of the tables, views, CTEs or subqueries in scope.
Example
SELECT naem FROM users;
error[E0002]: Column 'naem' not found in table 'users'
--> q.sql:1:8
|
1 | SELECT naem FROM users;
| ^^^^
= help: Did you mean 'name'?
Fixed:
SELECT name FROM users;
Notes
-
Typos, and columns renamed or dropped by a migration. This is the most common way a schema change breaks a query in another file. The help says what became of the column and names the schema file and line of the
ALTER TABLEthat changed it, so you can find the migration without searching:= help: 'body' was renamed to 'content' in db/migrations/0003_rename_body.sql:2 = help: 'nick' was dropped in db/migrations/0004_drop_nick.sql:1Paths are shown the way the schema files were given (relative to the current directory, or to the workspace in the editor). When the
ALTER TABLEis in the query file itself, the help saysat line N of this file. -
Columns of a subquery or CTE that the subquery doesn't select.
-
PostgreSQL: a column created with a quoted name that is not all lowercase (
"authorId", as Prisma migrations create them) is matched only by a quoted reference with the same case. PostgreSQL folds the unquotedauthorIdtoauthorid, so sqlsift reports it with the hintColumn names are case-sensitive when quoted; did you mean "authorId"?. Columns created unquoted or all lowercase match references in any case, and other dialects match column names case-insensitively.
Configuring
# sqlsift.toml
[rules]
column-not-found = "warn" # or "off"
Or for a single line: -- sqlsift:disable E0002. The examples use the schema on the Rules page.