Open ishwor-mis opened 9 years ago
So far it seems this parser is not capable of having (a and b) or (c and d). Since this is not a farfetched use case, it would be great to have this feature!
@Hakaze agreed
It needs to handle operator precedence properly.
:+1:
@ishwor-mis can you provide any insight on this issue?
What I have found is that if you want to do something like:
$filter=Name eq 'John' and LastName eq 'Doe' or MiddleName eq 'mdle' and emailAddress eq 'someeqm@gmail.com'
You must help this parser out by using grouping operators (
, and )
. If you do this, the parser will do a much better job at constructing the Abstract Syntax Tree (AST).
So I would change the aforementioned filter to:
$filter=(Name eq 'John' and LastName eq 'Doe') or (MiddleName eq 'mdle' and emailAddress eq 'someeqm@gmail.com')
The resulting AST will be much different (Array
based), but will be straightforward enough to decompose/map (via recursion).
The PEG grammar used still doesn't handle operator precedence correctly. But now that #23 is merged, there is a simple workaround - just use parenthesis in your $filter clause.
You mean like I did above? That's worked for some time now
Is it possible to handle a case where we need to handle complex or and and filters as the filter below?
$filter=Name eq 'John' and LastName eq 'Doe' or MiddleName eq 'mdle' and emailAddress eq 'someeqm@gmail.com'
Here I am trying to do the following
select * from sometable where Name='John' and (LastName='Doe' or MiddleName='mdle') and emailAddress='someeqm@gmail.com'