# missing-where

Default severity: **warn**

## What it does

Reports an `UPDATE` or `DELETE` with no `WHERE`, on its keyword: inside a CTE too, and with `UPDATE ... FROM` or `DELETE ... USING`.

```python
from sqlty import SQL

# error: [missing-where] "`DELETE` without `WHERE` removes every row of `users`: add a `WHERE`, or `WHERE true` to mean it"
q = SQL[tuple[()]]("--sql\nDELETE FROM users")
```

Any `WHERE` says the filter is meant, `WHERE true` included:

```python
from sqlty import SQL

# error:
q = SQL[tuple[()]]("--sql\nUPDATE users SET name = 'x' WHERE true")
```

## Why is this bad?

A forgotten `WHERE` rewrites or empties the whole table, and the database runs it without a complaint.

## How to fix

Add the `WHERE` the statement was meant to have, or `WHERE true` when it is meant to touch every row.

## Configuration

A warning by default: the statement is valid SQL. Turn it into an error or off:

```toml
[tool.sqlty.rules]
missing-where = "error"
```

Needs no schema. A MySQL `UPDATE` or `DELETE` with `LIMIT` is not reported, and migrations are not checked.
