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

multiple negate() ordering in query #991

Open
iamme9182 opened this issue Aug 1, 2023 · 1 comment
Open

multiple negate() ordering in query #991

iamme9182 opened this issue Aug 1, 2023 · 1 comment

Comments

@iamme9182
Copy link

I am trying to build a query to exclude mail matching multiple subjects and am not clear on the behaviour here.

If I add a query like this:

query = query.chain('or')
query = query.negate().on_attribute('subject').contains('value1')
query = query.negate().on_attribute('subject').contains('value2')

The query gets built as:

Filter: not contains(subject, 'value1') or contains(subject, 'value2')

I was expecting to have a 'not' in front of both contains() in the output.

It looks like if I move the negate() to the end of the 'value2' line it has the behaviour I expected and if I add additional contains with negates It looks like I would need to alternate the location of the negate() for each line. Is there a better way to order these to have the behaviour I expected?

@alejcas
Copy link
Member

alejcas commented Oct 19, 2023

To group sentences, use the Query functions "open_group" and "close_group". Those effectively adds groupings.

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

2 participants