E0024 unfiltered-write
UPDATE or DELETE without WHERE.
| Code | Name | Category | Default |
|---|---|---|---|
E0024 | unfiltered-write | restriction | off |
What it reports
An UPDATE or DELETE with no WHERE clause changes or deletes every row of the table. Teams that want every such statement to be deliberate can require a WHERE.
Example
DELETE FROM orders;
warning[E0024]: DELETE without WHERE deletes every row of the table
--> q.sql:1:13
|
1 | DELETE FROM orders;
| ^^^^^^
= help: Add a WHERE clause (WHERE true if every row is meant), or use TRUNCATE
Fixed:
DELETE FROM orders WHERE status = 'open';
Notes
Write WHERE true when every row is meant. MySQL's DELETE ... LIMIT n is not reported.
Configuring
This rule is off by default. To enable it:
# sqlsift.toml
[rules]
unfiltered-write = "warn" # or "error"
Or on the command line: -W unfiltered-write, or -W restriction for every restriction rule. The examples use the schema on the Rules page.