Skip to main content

Clarify Precedence

Adds explicit parentheses around AND groups inside OR expressions, making operator precedence visually unambiguous. SQL's precedence rules mean a OR b AND c is a OR (b AND c), but this is not obvious at a glance — especially in complex WHERE clauses.

Basic: AND inside OR gets parens

select * from t where a = 1 or b = 2 and c = 3
select * from t where a = 1 or (b = 2 and c = 3)

Multiple OR groups

select * from t where a = 1 or b = 2 and c = 3 or d = 4 and e = 5 and f = 6
select * from t where a = 1 or (b = 2 and c = 3) or (d = 4 and e = 5 and f = 6)

Pure AND — no parens needed

When there is no OR, AND conditions are not wrapped.

select * from t where a = 1 and b = 2 and c = 3
select * from t where a = 1 and b = 2 and c = 3

Pure OR — no parens needed

select * from t where a = 1 or b = 2 or c = 3
select * from t where a = 1 or b = 2 or c = 3

Off by default

Without clarifyPrecedence, AND groups inside OR are NOT wrapped.

select * from t where a = 1 or b = 2 and c = 3
select * from t where a = 1 or (b = 2 and c = 3)