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

Removing datastore key query filter restriction. #918

Merged
merged 1 commit into from
Jun 10, 2015

Conversation

dhermes
Copy link
Contributor

@dhermes dhermes commented Jun 8, 2015

Also checking in Query constructor that all the filters are valid.

Fixes #917.


@pcostell Can you verify that key inequality filters work? (The docs clearly state they do, just want to be careful.) This has been in the codebase longer than I've been working on the project, so maybe it was introduced before inequality filters were allowed?

Also checking in `Query` constructor that all the filters
are valid.

Fixes googleapis#917.
@dhermes dhermes added the api: datastore Issues related to the Datastore API. label Jun 8, 2015
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jun 8, 2015
@pcostell
Copy link
Contributor

pcostell commented Jun 8, 2015

Yes, key inequalities are allowed.

@tseaver
Copy link
Contributor

tseaver commented Jun 9, 2015

@pcostell does the API allow arbitrary rich comparisons on keys (<, <=, >, >=), or just "not equal" (!=). If ordering comparisons are allowed, how is the ordering done?

from gcloud.datastore.key import Key
_DATASET = 'DATASET'
key = Key('Foo', dataset_id='DATASET')
query = self._makeOne(dataset_id=_DATASET)
self.assertRaises(ValueError, query.add_filter, '__key__', '<', key)
query.add_filter('__key__', '<', key)
self.assertEqual(query.filters, [('__key__', '<', key)])

This comment was marked as spam.

@dhermes
Copy link
Contributor Author

dhermes commented Jun 9, 2015

@tseaver check out #917 for your answer

@tseaver
Copy link
Contributor

tseaver commented Jun 9, 2015

I see that @vinays uses >= as the operator in his workaround: I'm just not sure whether / how the back-end interprets ordering comparisons on keys (as opposed to simple equality / inequality).

@pcostell
Copy link
Contributor

pcostell commented Jun 9, 2015

Yes I mean <, >, <=, and >=. Like property filters, != is not supported. Ordering is performed on the key path tuples and names are always greater than ids. So
(MyParent, 123), (MyKind, "bar") > (MyParent, 123), (MyKind, 12) > (MyParent, 123), (MyKind, 6) > (MyParent, 123) > (MyParent, 122)

@tseaver
Copy link
Contributor

tseaver commented Jun 10, 2015

@pcostell OK, thanks. For future reference, I found the docs for key filters which describe those semantics (but not as clearly as you did :).

@tseaver
Copy link
Contributor

tseaver commented Jun 10, 2015

@dhermes LGTM

dhermes added a commit that referenced this pull request Jun 10, 2015
Removing datastore key query filter restriction.
@dhermes dhermes merged commit 319963f into googleapis:master Jun 10, 2015
@dhermes dhermes deleted the fix-917 branch June 10, 2015 19:00
@dhermes dhermes mentioned this pull request Jul 10, 2015
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 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.

4 participants