10000 DataStore: query.add_filter return self · Issue #5 · googleapis/python-datastore · GitHub
[go: up one dir, main page]

Skip to content
DataStore: query.add_filter return self #5
Closed
@cha0sCat

Description

@cha0sCat

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.

Metadata

Metadata

Labels

api: datastoreIssues related to the googleapis/python-datastore API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0