This repository was archived by the owner on May 6, 2026. It is now read-only.
Sort out Query options.#60
Merged
Merged
Conversation
Make use of the ``default_options`` argument to the ``Query`` constructor. Make all arguments to ``Query.fetch`` explicit, and perform the complicated dance of merging all the arguments and options to both the ``Query`` constructor and ``Query.fetch`` into a single set of options for passing to ``_datastore_query.fetch``.
chrisrossi
commented
Apr 4, 2019
|
|
||
| class QueryOptions: | ||
| __slots__ = ( | ||
| "client", |
chrisrossi
commented
Apr 4, 2019
| class QueryOptions: | ||
| __slots__ = ( | ||
| "client", | ||
| # Query options |
Contributor
Author
There was a problem hiding this comment.
I've tried to organize these according to which ones are passed to the Query constructor and which ones are passed to Query.fetch. projection is passed to both.
chrisrossi
commented
Apr 4, 2019
| if config is not None and not isinstance(config, QueryOptions): | ||
| raise TypeError("Config must be a QueryOptions instance.") | ||
|
|
||
| for key in self.__slots__: |
Contributor
Author
There was a problem hiding this comment.
Refactored to avoid AttributeError when accessing an attribute that wasn't explicitly passed in.
chrisrossi
commented
Apr 4, 2019
| default = getattr(config, key, None) if config else None | ||
| setattr(self, key, kwargs.get(key, default)) | ||
|
|
||
| def __eq__(self, other): |
Contributor
Author
There was a problem hiding this comment.
To support unit tests.
cguardia
approved these changes
Apr 4, 2019
cguardia
left a comment
Contributor
There was a problem hiding this comment.
Looking good. Really a lot simpler than before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make use of the
default_optionsargument to theQueryconstructor. Make all arguments to
Query.fetchexplicit, and performthe complicated dance of merging all the arguments and options to both
the
Queryconstructor andQuery.fetchinto a single set ofoptions for passing to
_datastore_query.fetch.