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

DataStore: query.add_filter return self #5

Closed
cha0sCat opened this issue Nov 21, 2019 · 0 comments · Fixed by #12
Closed

DataStore: query.add_filter return self #5

cha0sCat opened this issue Nov 21, 2019 · 0 comments · Fixed by #12
Assignees
Labels
api: datastore Issues related to the googleapis/python-datastore API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@cha0sCat
Copy link

this method return an None type
original code like this

# class google.cloud.datastore.query.Query
class Query(object):
    ........
    def add_filter(self, property_name, operator, value):
        if self.OPERATORS.get(operator) is None:
            error_message = 'Invalid expression: "%s"' % (operator,)
            choices_message = "Please use one of: =, <, <=, >, >=."
            raise ValueError(error_message, choices_message)

        if property_name == "__key__" and not isinstance(value, Key):
            raise ValueError('Invalid key: "%s"' % value)

        self._filters.append((property_name, operator, value))

This makes it impossible to add filtering and fetch it on one line

Please let it return it self!

Therefore you can code like this:
query_results = client.query(kind='Task').add_filter("name", "=", "something").fetch()

Code modification requires only one line, but this will be of great benefit.

@HemangChothani HemangChothani self-assigned this Nov 22, 2019
@HemangChothani HemangChothani changed the title Let google.cloud.datastore.query.add_filter return it self! DataStore: query.add_filter return self Nov 22, 2019
@crwilcox crwilcox transferred this issue from googleapis/google-cloud-python Feb 7, 2020
@crwilcox crwilcox added api: datastore Issues related to the googleapis/python-datastore API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Feb 7, 2020
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. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants