org.sonar.l10n.plsqlopen.rules.plsql.AddParenthesesInNestedExpression.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zpa-checks Show documentation
Show all versions of zpa-checks Show documentation
Z PL/SQL Analyzer :: Checks
The newest version!
An AND condition has a higher precedence than an OR condition, so you should wrap the AND condition in parentheses
for clarity and to ensure that the operators are evaluated in the order that you intend.
Consider this example:
SELECT dogs.name
FROM dogs
WHERE dogs.sex = 'male'
and dogs.color = 'white'
or dogs.size = 'big';
Without parentheses, one would think that it is equivalent to:
SELECT dogs.name
FROM dogs
WHERE dogs.sex = 'male'
and (dogs.color = 'white' or dogs.size = 'big');
But the original query is parsed as:
SELECT dogs.name
FROM dogs
WHERE (dogs.sex = 'male' and dogs.color = 'white')
or dogs.size = 'big';