Skip to content

tests: add coverage for skip < offset case #165

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

Merged
merged 2 commits into from
May 18, 2021

Conversation

tseaver
Copy link
Contributor

@tseaver tseaver commented May 3, 2021

Closes #158

@tseaver tseaver requested a review from a team May 3, 2021 21:46
@tseaver tseaver requested a review from a team as a code owner May 3, 2021 21:46
@product-auto-label product-auto-label bot added the api: datastore Issues related to the googleapis/python-datastore API. label May 3, 2021
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label May 3, 2021
@tseaver tseaver requested review from craiglabenz and crwilcox May 4, 2021 19:25
@@ -593,8 +593,12 @@ def _next_page(self):
# skipped all of the results yet. Don't return any results.
# Instead, rerun query, adjusting offsets. Datastore doesn't process
# more than 1000 skipped results in a query.
old_query_pb = query_pb
query_pb = query_pb2.Query()
query_pb._pb.CopyFrom(old_query_pb._pb) # copy for testability
Copy link
Contributor

Choose a reason for hiding this comment

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

@craiglabenz is this going to hit the bad path for perf and protoplus?

I have hesitation about making a product change to make it possible to test. Can you shed more light on this change @tseaver

Copy link
Contributor Author

@tseaver tseaver May 18, 2021

Choose a reason for hiding this comment

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

For perf:

  • We are dealing with the raw protos here -- no protoplus attributes are touched, and CopyFrom is super-fast (implemented in C).
  • The copy will only be made once per page, in the edge case where we are skipping over more than a page of results.

For correctness:

  • Scribbling on the original query_pb is a puzzlement, and might actually defeat some forms of debugging (maybe even a full-retry of the query, if needed somehow?)

Copy link
Contributor

@chrisrossi chrisrossi left a comment

Choose a reason for hiding this comment

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

LGTM

@tseaver tseaver merged commit 0da3e22 into master May 18, 2021
@tseaver tseaver deleted the 158-add_coverage_for_query_offset_fix branch May 18, 2021 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the googleapis/python-datastore API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add coverage for query offset fix
3 participants