G-2150
🆓Error
Avoid comparisons with NULL value, consider using IS [NOT] NULL.
Reason
The null value can cause confusion both from the standpoint of code review and code execution. You must always use the is null or is not null syntax when you need to check if a value is or is not null.
Example
Non-Compliant Example
declare
l_value integer;
begin
if l_value = null then
null;
end if;
end;
/Issues
| Line | Column | Message |
|---|---|---|
| 4 | 7 |
Compliant Solution - ★★★★★
declare
l_value integer;
begin
if l_value is null then
null;
end if;
end;
/Parameters
Use parameters to customize the rule to your needs.
| Parameter | Description | Default Value |
|---|---|---|
| EmptyStringIsNull | Should an empty string be treated as a null value? 1=yes (as in OracleDB), 0=no (as in PostgreSQL). | 1 |
| DisableAllQuickFix | Comma-separated list of rules for which a quick fix should not be applied to all the problems in a file. | Core G-3130 |
References
- same as plsql:NullComparison
- same as SQLFluff convention.is_null
- same as plsqlopen:ComparisonWithNull
- same as Trivadis G-2150