Boolean precedence issues within Queries
Closed this issue · 0 comments
If I have a number of records where fields look like:
...
<A>1</A>
<B>2</B>
...
interspersed with records with fields like:
...
<A>2</A>
<B>1</B>
...
and a number of records which match neither of the above.
Create a Query against this data.
Running a filter of A = "1" and B = "2"
returns 4 records.
Running a filter of A = "2" and B = "1"
returns 7 records.
A filter of A = "1" and B = "2" or A = "2" and B = "1"
returns 7 records (should be 11).
A filter of (A = "2" and B = "2") or (A = "2" and B = "1")
returns 11 records (correct).
A filter of A = "1" and B = "2" or A = "not2" and B = "not1"
returns 0 records (should be 4).
A filter of A = "not1" and B = "not2" or A = "2" and B = "1"
returns 7 records (correct).
all the above where not1
and not2
are values that never appear in the data.
It looks like the ANDs are not being handled before the ORs as expected, but the operators are being parsed sequentially in reverse order.