E0001 table-not-found
Referenced table does not exist in schema.
| Code | Name | Category | Default |
|---|---|---|---|
E0001 | table-not-found | correctness | error |
What it reports
A query refers to a table or view that isn't defined in the schema, and isn't a CTE or a table created earlier in the same file.
Example
SELECT * FROM user;
error[E0001]: Table 'user' not found
--> q.sql:1:15
|
1 | SELECT * FROM user;
| ^^^^
= help: Did you mean 'users'?
Fixed:
SELECT * FROM users;
Notes
- Typos in a table name. sqlsift suggests the closest existing name.
- A table that was renamed or dropped by a later migration. The help names the schema file and line of the
ALTER TABLE ... RENAME TOorDROP TABLE('people' was renamed to 'persons' in db/migrations/0005_rename_people.sql:2), or the line of the query file when the change is in the query file itself ('tmp' was dropped at line 3 of this file). - A table created in a migration that sqlsift didn't load. Run
sqlsift schemato see what was loaded, and check the order of files in--schema-dir. - Qualifying a column with a table's name after giving the table an alias (
SELECT users.id FROM users u). Once aliased, the table must be referred to by its alias:Table or alias 'users' not found in FROM clause.
Configuring
# sqlsift.toml
[rules]
table-not-found = "warn" # or "off"
Or for a single line: -- sqlsift:disable E0001. The examples use the schema on the Rules page.