-
Notifications
You must be signed in to change notification settings - Fork 373
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
Fix comparison with unset fields #1634
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
2f85aa5
to
e7490b0
Compare
e7490b0
to
d370af9
Compare
d370af9
to
eb569d9
Compare
eb569d9
to
79a4408
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1634 +/- ##
==========================================
- Coverage 68.49% 68.48% -0.02%
==========================================
Files 285 285
Lines 13857 13857
==========================================
- Hits 9492 9490 -2
+ Misses 3433 3432 -1
- Partials 932 935 +3
Flags with carried forward coverage won't be shown. Click here to find out more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I need more context to review the PR. What issues does it fix?
I see the one in elemMatch
where we check filterKey
in the document, what else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'm also struggling a little bit with understanding the scope of this PR.
If I understand there's an issue that we handle unset values as nulls, and mongodb differentiate between them, right? Also there's a new TestQueryCompatSort
test which is a result of finding some sorting bug in our compat test?
@rumyantseva @noisersup thanks for the feedback, I added description of PR and comments in the code. |
@noisersup if we see |
@rumyantseva fix in this PR is about errors that was produced by adding
And added a new test case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the extended explanation, it's made it easier to understand what's going on here 😃
Description
Closes #1023.
This PR is about making unset work the same way as mongoDB. In the issue there is a link to a close #1024 which shows that unset comparison had issues. In this PR, we compare
unset
field withnull
field using compat dataset and tests. SeeUnset
field being un-commented in the Scalar shareddata, so every compat test is run onUnset
bson.For a field
v
which is used in integration test, unset BSON looks like{_id: "unset"}
, while null field BSON looks like{_id: "null", v: null}
.What was done before this PR:
We checked if filter was null filter, if it was it returned
true
indicating match, otherwise it returnedfalse
. So it returned early based on the filter value beingnull
or not. And this would fail on operator such as$gt
,$lt
,$nin
and$in
. For example when comparing with filter{v: {$gt: null}
on{_id: "unset"}
we returnedtrue
before this PR. But compat test tells us it should befalse
.What we change:
The field is set to
null
on unset value and let the comparisonCompare(a, b any)
do the work on returning result.Readiness checklist
task all
, and it passed.task godocs
.@FerretDB/core
), Assignee, Labels, Project and project's Sprint fields.