E0026 select-star
SELECT * in a query's result columns.
| Code | Name | Category | Default |
|---|---|---|---|
E0026 | select-star | restriction | off |
What it reports
SELECT * or t.* in the columns a statement returns (also in each branch of UNION and in INSERT ... SELECT). The result changes when a column is added to the table, which can break or slow down the application reading it.
Example
SELECT * FROM orders WHERE user_id = 1;
warning[E0026]: SELECT * returns whatever columns the tables have
--> q.sql:1:8
|
1 | SELECT * FROM orders WHERE user_id = 1;
| ^
= help: List the columns the query needs
Fixed:
SELECT id, status, total FROM orders WHERE user_id = 1;
Notes
A star inside a subquery, CTE or EXISTS (SELECT * ...) doesn't change the result columns and is not reported, nor is count(*).
Configuring
This rule is off by default. To enable it:
# sqlsift.toml
[rules]
select-star = "warn" # or "error"
Or on the command line: -W select-star, or -W restriction for every restriction rule. The examples use the schema on the Rules page.