odata-query
odata-query copied to clipboard
'not' operator is being applied only to the first condition with and/or operators
I've tried to use the new 'not' operator for some of my logic while I noticed it doesn't get applied correctly - it is applied 'not' to the first condition instead of the whole group
It loolks like the example presents the issue as well: const filter = { not: { and:[ {SomeProp: 1}, {AnotherProp: 2} ] } };
buildQuery({ filter }) => '?$filter=(not (SomeProp eq 1) and (AnotherProp eq 2))'
It should be => '?$filter=(not ((SomeProp eq 1) and (AnotherProp eq 2)))'
as otherwise it would be considered as (not SomeProp eq 1) and (AnotherProp eq 2)
I can't implement { not: { prop: { in: [...] } } } pattern. I couldn't succeed to use NOT with IN operator.
bump
As of the current version (09/2022), brackets are always put around what follows not
, see
https://github.com/techniq/odata-query/blob/master/src/index.ts#L567-L569
So this issue can probably be closed?
@hakan-bilgin I do exactly that and it works with the current version.
Note that the generated $filter
is lacking a required whitespace, which might be an issue depending on who parses the filter, I opened #110 for that.