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
feat(firestore): support "!=" and "not-in" query operators #3207
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@googlebot I signed it! |
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.
Thank you! Looks good! Would you mind adding an integration test?
google-cloud-go/firestore/integration_test.go
Lines 652 to 660 in 581bf92
{q, wants}, | |
{q.Where("q", ">", 1), wants[2:]}, | |
{q.WherePath([]string{"q"}, ">", 1), wants[2:]}, | |
{q.Offset(1).Limit(1), wants[1:2]}, | |
{q.StartAt(1), wants[1:]}, | |
{q.StartAfter(1), wants[2:]}, | |
{q.EndAt(1), wants[:2]}, | |
{q.EndBefore(1), wants[:1]}, | |
{q.LimitToLast(2), wants[1:]}, |
I actually don't see most operators tested in the integration test-- maybe we can deal with that separately? |
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.
Looks good to me. @BenWhitehead @crwilcox FYI
I'd prefer to do it now. Existing poor coverage is not a good reason to avoid new coverage. 😃 |
3c00c2e
to
12ca3f8
Compare
Hey, I added some integration tests for value operators. I hope understood the testing logic correctly. |
12ca3f8
to
30aec42
Compare
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.
One more test case then LGTM.
{q.Where("q", "<", 1), wants[:1]}, | ||
{q.Where("q", "==", 1), wants[1:2]}, | ||
{q.Where("q", "!=", 0), wants[1:]}, | ||
{q.Where("q", ">=", 1), wants[1:]}, | ||
{q.Where("q", "<=", 1), wants[:2]}, |
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.
Thank you for adding these! Would you mind doing one more for not-in?
Is it true that I cannot see the kokoro test results? It just says "Expected - Waiting for status to be reported" (maybe I'm just blind...) |
The tests just haven't run on the latest commit yet. I triggered them again. |
Firestore Version 7.21.0 - September 17, 2020 - introduced support for the "!=" (NOT_EQUAL) and "not-in" (NOT_IN) query operators: https://firebase.google.com/support/release-notes/js#version_7210_-_september_17_2020 Query operator documentation: https://firebase.google.com/docs/firestore/query-data/queries This patch adds support for these two new operators and adds test cases for them.
30aec42
to
59a87e0
Compare
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.
Looks like a couple other tests are failing as a result of this change:
=== RUN TestQueryToProto
query_test.go:81: firestore: must use '==' when comparing NaN
--- FAIL: TestQueryToProto (0.00s)
=== RUN TestQueryToProtoErrors
query_test.go:492: query 1 "{c:0xc0003b9aa0 path:projects/P/databases/DB/documents/C parentPath:projects/P/databases/DB/documents collectionID:C selection:[] filters:[{fieldPath:[x] op:!= value:1}] orders:[] offset:0 limit:<nil> limitToLast:false startVals:[] endVals:[] startDoc:<nil> endDoc:<nil> startBefore:false endBefore:false err:<nil> allDescendants:false}": got nil, want error
--- FAIL: TestQueryToProtoErrors (0.00s)
Also, we'll take care of squashing and editing the commit message when we merge the PR. So, you can add commits as you go, rather than force pushing every time. |
Yes, I saw that. Should be fixed now.
Cool, thanks! |
firestore/integration_test.go
Outdated
{q.Where("q", "in", [0, 1]), wants[:2]}, | ||
{q.Where("q", "not-in", [0, 1]), wants[2:]}, |
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.
Looks like you need to fully initialize the slice here. Something like:
{q.Where("q", "in", [0, 1]), wants[:2]}, | |
{q.Where("q", "not-in", [0, 1]), wants[2:]}, | |
{q.Where("q", "in", []int{0, 1}), wants[:2]}, | |
{q.Where("q", "not-in", []int{0, 1}), wants[2:]}, |
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.
Thank you for implementing this!
Thank you for your kind support and pushing me all the way through! :-) |
@jacksgt would you mind testing with a pseudo-version to make sure it's all working well for you before we tag a release? |
Yes, sure!
And ran my application again - it works! |
Thanks for confirming! |
…oogleapis#3207)" This reverts commit 5c44019. Reverting due to integration test failure. Fixes googleapis#3223
Glad it worked! This needed a small update to make the integration test pass, but otherwise seems to be working well. |
Firestore Version 7.21.0 - September 17, 2020 - introduced support for
the "!=" (NOT_EQUAL) and "not-in" (NOT_IN) query operators:
https://firebase.google.com/support/release-notes/js#version_7210_-_september_17_2020
Query operator documentation:
https://firebase.google.com/docs/firestore/query-data/queries
This patch adds support for these two new operators and adds test
cases for them.
Closes #2974 #2974