Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'not' operator is being applied only to the first condition with and/or operators #43

Open
relair opened this issue Oct 2, 2019 · 3 comments

Comments

@relair
Copy link

relair commented Oct 2, 2019

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)

@hakan-bilgin
Copy link

hakan-bilgin commented Dec 6, 2019

I can't implement { not: { prop: { in: [...] } } } pattern. I couldn't succeed to use NOT with IN operator.

@regexer-github
Copy link

bump

@jods4
Copy link
Contributor

jods4 commented Sep 5, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants