Skip to main content

Identical expressions should not be used on both sides of an operator

ZPA rule for PL/SQL and Oracle SQL · IdenticalExpression

A comparison with the same expression on both sides is almost always a mistake: usually a copy and paste where one side should name another column, variable or alias. When it is not, it is a hidden test for null: x = x is true for any value and unknown for null, which x IS NOT NULL says plainly.

This rule reports a comparison (=, <>, <, >, <=, >=...) whose two sides are the same expression, parentheses aside.

Examples​

Noncompliant Code Example
select c.code
from crate c, rack r
where c.rack_id = c.rack_id; -- Noncompliant
Compliant Solution
select c.code
from crate c, rack r
where c.rack_id = r.id;