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

fix: strip order_by option from query when using count() #452

Merged
merged 1 commit into from
May 27, 2020

Conversation

chrisrossi
Copy link
Contributor

A fairly standard use case is to precompose a query and then call
methods like fetch or count as needed. In this case you might call
count() on a query with an order_by option. Previously, if the query
was also a multiquery, this could cause an error as we'd be trying to
sort on the client side using data that wasn't there, because we'd
converted the query to keys_only for purposes of getting a count.

This fixes that problem by stripping order_by from the query options
when count() is called.

Fixes #447

A fairly standard use case is to precompose a query and then call
methods like `fetch` or `count` as needed. In this case you might call
`count()` on a query with an `order_by` option. Previously, if the query
was also a multiquery, this could cause an error as we'd be trying to
sort on the client side using data that wasn't there, because we'd
converted the query to `keys_only` for purposes of getting a count.

This fixes that problem by stripping `order_by` from the query options
when `count()` is called.

Fixes googleapis#447
@chrisrossi chrisrossi requested a review from cguardia May 27, 2020 17:13
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 27, 2020
Copy link
Contributor

@cguardia cguardia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work.

@chrisrossi chrisrossi merged commit 9d20a2d into googleapis:master May 27, 2020
@chrisrossi chrisrossi deleted the fix-447 branch May 27, 2020 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

count() fails if order_by present in a query
3 participants