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

When querying MongoDB, if there are multiple 'not in' or '!=' statements in the 'where' clause, the query results may be abnormal. #19404

Closed
huangfox opened this issue Oct 14, 2023 · 2 comments · Fixed by #19429
Labels
bug Something isn't working correctness

Comments

@huangfox
Copy link

For example, there is a MongoDB data collection with three records.
image

When executing the following statement, the query results are abnormal.
select * from test_user where id !=1 and flag!=0;
image
The filter condition 'id != 1' did not take effect.

If only the 'id != 1' filter condition is present, the query results are correct.
select * from test_user where id !=1 ;
image

@huangfox
Copy link
Author

This exception started occurring from version 402.

@hashhar hashhar added bug Something isn't working correctness labels Oct 16, 2023
@ebyhr
Copy link
Member

ebyhr commented Oct 17, 2023

MongoSession#buildQuery method has a bug. The 1st predicate is overwritten by the 2nd predicate in the for loop because the internal key $or is duplicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctness
Development

Successfully merging a pull request may close this issue.

3 participants