Repository navigation
fix(datastore): support IN and NOT_IN operators on __key__ filters #19076
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,6 +153,38 @@ def test_query_key_filter(query_client, ancestor_query, database_id): | |
| assert len(entities) == expected_matches | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("database_id", [None, _helpers.TEST_DATABASE], indirect=True) | ||
| def test_query_key_filter_in(query_client, ancestor_query, database_id): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have we verified
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added a test, thanks |
||
| query = ancestor_query | ||
| rickard_key = query_client.key(*populate_datastore.RICKARD) | ||
| eddard_key = query_client.key(*populate_datastore.EDDARD) | ||
| query.add_filter(filter=PropertyFilter("__key__", "IN", [rickard_key, eddard_key])) | ||
| expected_matches = 2 | ||
|
|
||
| entities = _do_fetch(query, limit=expected_matches + 1) | ||
|
|
||
| assert len(entities) == expected_matches | ||
| assert {entity.key for entity in entities} == {rickard_key, eddard_key} | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("database_id", [None, _helpers.TEST_DATABASE], indirect=True) | ||
| def test_query_key_filter_not_in(query_client, ancestor_query, database_id): | ||
| query = ancestor_query | ||
| rickard_key = query_client.key(*populate_datastore.RICKARD) | ||
| eddard_key = query_client.key(*populate_datastore.EDDARD) | ||
| query.add_filter( | ||
| filter=PropertyFilter("__key__", "NOT_IN", [rickard_key, eddard_key]) | ||
| ) | ||
| expected_matches = len(populate_datastore.CHARACTERS) - 2 | ||
|
|
||
| entities = _do_fetch(query, limit=expected_matches + 1) | ||
|
|
||
| assert len(entities) == expected_matches | ||
| returned_keys = {entity.key for entity in entities} | ||
| assert rickard_key not in returned_keys | ||
| assert eddard_key not in returned_keys | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("database_id", [None, _helpers.TEST_DATABASE], indirect=True) | ||
| def test_query_w_order(ancestor_query, database_id): | ||
| query = ancestor_query | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.