Skip to content

else-null

SQLcleanupno fixdefault: warnsql/sqlfluff

Reports a CASE branch ELSE NULL.

A CASE that does not match returns NULL without an ELSE, so the branch says what is already the case.

To fix, remove the ELSE NULL.

Reported
...
select a from t left join u on t.a = u.a;
select case when a then 1 else null end, case when a then 1 else 2 end from t;
...
sql:
lint:
rules:
else-null: warn # off, warn (default), error

Enabled by the presets: sql/sqlfluff.

Suppress one line with sudsy-disable-next-line else-null in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
sqlfluff ST01 full