Skip to content

fix(datastore): support IN and NOT_IN operators on __key__ filters - #19076

Merged
daniel-sanche merged 3 commits into
mainfrom
fix_datastore_key_in_filter_google-cloud-datastore_15339
Nov 25, 2026
Merged

daniel-sanche merged 3 commits into
mainfrom
fix_datastore_key_in_filter_google-cloud-datastore_15339

Conversation

@daniel-sanche

Copy link
Copy Markdown
Contributor

Previously, filters against key required a single key, which means IN and NOT_IN oeprators, which depend on a list of keys, would be rejected

This PR extends the validation to allow lists of keys for these operators, while still requiring a single key for others

Fixes #15339

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for filtering on __key__ using the IN and NOT_IN operators with a list of keys, updating the validation logic, protobuf generation, docstrings, and adding corresponding unit and system tests. The review feedback recommends extending this support to accept both list and tuple types for sequence parameters to align with Python idioms, along with updating the relevant docstrings and test cases.

@daniel-sanche
daniel-sanche marked this pull request as ready for review November 16, 2026 17:33
@daniel-sanche
daniel-sanche requested a review from a team as a code owner November 16, 2026 17:33


@pytest.mark.parametrize("database_id", [None, _helpers.TEST_DATABASE], indirect=True)
def test_query_key_filter_in(query_client, ancestor_query, database_id):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we verified NOT_IN on __key__ against live Datastore too? If it's supported with ancestor_query, might be nice to cover it here alongside IN.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a test, thanks

@daniel-sanche
daniel-sanche requested review from a team as code owners November 25, 2026 23:12
@daniel-sanche
daniel-sanche requested review from sycai and removed request for a team November 25, 2026 23:12
@daniel-sanche
daniel-sanche force-pushed the fix_datastore_key_in_filter_google-cloud-datastore_15339 branch from 90293bb to bee845a Compare November 25, 2026 23:15
@daniel-sanche daniel-sanche added the cla: yes This human has signed the Contributor License Agreement. label Nov 25, 2026
@google-cla google-cla Bot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Nov 25, 2026
@daniel-sanche daniel-sanche added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Nov 25, 2026
@google-cla google-cla Bot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Nov 25, 2026
@daniel-sanche daniel-sanche added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Nov 25, 2026
@daniel-sanche
daniel-sanche merged commit e40fb36 into main Nov 25, 2026
83 checks passed
@daniel-sanche
daniel-sanche deleted the fix_datastore_key_in_filter_google-cloud-datastore_15339 branch November 25, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IN operator with __key__ property does not work

2 participants