-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 does not allow inequality filter on __key__ property. #917
Labels
api: datastore
Issues related to the Datastore API.
Comments
For those who are facing the same issue; Workaround is to pass filters for query = datastore.Query('Kind')
query.add_filter('__key__', '>=', datastore.Key('Kind', '<startname>'))
query.add_filter('__key__', '<', datastore.Key('Kind', '<endname>'))
entities = query.fetch() Use: start_key = datastore.Key('Kind', '<startname>')
end_key = datastore.Key('Kind', '<endname>')
queries = datastore.Query('Kind', filters=[('__key__', '>=', start_key), ('__key__', '<', end_key)])
entities = query.fetch() |
Thanks @vinays I'm not sure why we limit in if property_name == '__key__':
if not isinstance(value, Key):
raise ValueError('Invalid key: "%s"' % value)
if operator != '=':
raise ValueError('Invalid operator for key: "%s"' % operator) It also points out that the initial filters from the constructor aren't being verified. I really appreciate it and will be making a fix ASAP! |
dhermes
added a commit
to dhermes/google-cloud-python
that referenced
this issue
Jun 8, 2015
Also checking in `Query` constructor that all the filters are valid. Fixes googleapis#917.
(thumbsup) @dhermes thanks for quick response and fix. |
👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Datastore query raises a ValueError for inequality(non-equality to be correct) operators on
__key__
property.https://github.com/GoogleCloudPlatform/gcloud-python/blob/3e86aaed3c7e192a17d9b790f90a41cc2b7baa6a/gcloud/datastore/query.py#L223
According to Google Cloud Datastore documentation inquality operators on
__key__
property are supported, and should not raise exception.https://cloud.google.com/datastore/docs/concepts/queries#Datastore_Key_filters
It is a critical part of our data-model.
The text was updated successfully, but these errors were encountered: