rspec/rules/S2527/tsql/rule.adoc

20 lines
541 B
Plaintext
Raw Normal View History

2020-12-23 14:59:06 +01:00
In a Zen-like manner, "NULL" is never equal to anything, even itself. Therefore comparisons using equality operators will always return ``False``, even when the value actually ``IS NULL``.
2020-06-30 12:48:07 +02:00
2020-12-23 14:59:06 +01:00
For that reason, comparison operators should never be used to make comparisons with ``NULL``; ``IS NULL`` and ``IS NOT NULL`` should be used instead.
2020-06-30 12:48:07 +02:00
== Noncompliant Code Example
----
UPDATE books
SET title = 'unknown'
WHERE title = NULL -- Noncompliant
----
== Compliant Solution
----
UPDATE books
SET title = 'unknown'
WHERE title IS NULL
----