rspec/rules/S2527/tsql/rule.adoc

21 lines
562 B
Plaintext
Raw Normal View History

2021-01-27 13:42:22 +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
2021-02-02 15:02:10 +01:00
2021-01-27 13:42:22 +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
----