-
Notifications
You must be signed in to change notification settings - Fork 536
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): Add Query#limit_to_last #7575
Conversation
new_start_at = new_query.end_at.dup | ||
new_end_at = new_query.start_at.dup | ||
new_query.start_at = new_start_at | ||
new_query.end_at = new_end_at |
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.
You also need to switch the "before" direction.
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.
Fixed, thanks!
|
||
_(snps.count).must_equal 2 | ||
_(snps[0].count).must_equal 2 | ||
_(snps[0].docs.map(&:document_id)).must_equal ["int 3", "int 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.
Can we make sure this test verifies that the order is "int 2", "int 3"?
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 catching that, will do. I'll also change line 65 below to ["int 3", "int 4"]
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.
@schmidt-sebastian Can you see the mistake I made in the implementation that causes this result? This is an integration test that currently passes.
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 can take a look at the code if you need me to, but I haven't yet. My strong suspicion is that you are using the flipped query but not re-flipping the results (you always need to reverse the results if you are flipping the orderBy constraints on the user's behalf). The way I do this is Node and Java is that I use the pre-flipped query to process the local results.
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.
That sounds likely, thank you.
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.
@schmidt-sebastian I updated Inventory
to reverse the results for limit_to_last
queries. I'm sorry I missed that the first time. Please take a look at the additional assertions for changes
ordering to verify that it is correct. (I'm not sure if changes
ordering should reflect query orderBy
.)
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.
This looks correct now. It is slightly different than what I have implemented since the Watch client in Ruby uses the reversed query Proto for its ordering, rather than the user-specified Query order. In the end this does not matter though, since we only need to match the user's order by clause. With the reversal this is now working as intended.
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.
@schmidt-sebastian Thank you for your help on this PR! I'm going to add samples for this feature (as in GoogleCloudPlatform/python-docs-samples#4196), then ask @dazuma to review for Ruby concerns.
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.
Here are the 3 samples PRs I found:
Go PR: GoogleCloudPlatform/golang-samples#1599
Python PR: GoogleCloudPlatform/python-docs-samples#4196
Node PR: googleapis/nodejs-firestore#1113
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.
Added sample in 13c2253
5b17b00
to
702ea24
Compare
Rebased on latest master to get |
* Support updating limit_to_last limit value without reflipping cursors
9dd8dd9
to
13c2253
Compare
13c2253
to
e3a45fc
Compare
closes: #7572
closes: #7594
/cc @schmidt-sebastian