null-comparison (GN024)#
Automatic fix is available.
What it does#
Checks for comparison with NULL.
Why not?#
Comparing NULL to NULL with = returns NULL, not true. Comparing a value to NULL returns neither true nor false, but NULL.
Do not write expression = NULL because NULL is not equal to NULL. (The null value represents an unknown value, and it is not known whether two unknown values are equal.)
When should you?#
Never.
Use instead:#
To check whether a value is or is not null, use the predicates:
- expression IS NULL
- expression IS NOT NULL