GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — datastore: Query does not allow inequality filter on __key__ property. · Issue #917 · googleapis/google-cloud-python

datastore: Query does not allow inequality filter on __key__ property. #917

New issue
Copy link
New issue
Copy link
Closed
Closed
datastore: Query does not allow inequality filter on __key__ property.#917
Copy link
Assignees
dhermes
Labels
api: datastoreIssues related to the Datastore API.

Description

@vinays
vinays
opened on Jun 8, 2015
Issue body actions

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.

Activity

  1. vinays commented on Jun 8, 2015

    @vinays
    vinays
    on Jun 8, 2015
    Author
    More actions

    For those who are facing the same issue; Workaround is to pass filters for __key__ property at the time of query construction.
    Example:
    Instead of:

    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()
  2. dhermes commented on Jun 8, 2015

    @dhermes
    dhermes
    on Jun 8, 2015
    Contributor
    More actions

    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!

  3. dhermes
    added a commit that references this issue on Jun 8, 2015

    Removing datastore key query filter restriction.

    This issue will close once commit 3c1168c is merged into the 'master' branch.
    3c1168c
  4. vinays commented on Jun 10, 2015

    @vinays
    vinays
    on Jun 10, 2015
    Author
    More actions

    (thumbsup) @dhermes thanks for quick response and fix.

  5. dhermes
    closed this as completedin #918on Jun 10, 2015
  6. dhermes commented on Jun 10, 2015

    @dhermes
    dhermes
    on Jun 10, 2015
    Contributor
    More actions

    👍

  7. dhermes
    added
    api: datastoreIssues related to the Datastore API.
    on Dec 31, 2015
  8. JustinBeckwith
    assigned
    dhermes
    on Feb 1, 2021
  9. parthea
    added a commit that references this issue on Aug 21, 2025

    chore: Update gapic-generator-python to 1.23.6 (#917)

    a694aad
  10. parthea
    added a commit that references this issue on Sep 16, 2025

    chore: Update gapic-generator-python to 1.23.6 (#917)

    2d2c4a7
  11. parthea
    added 7 commits that reference this issue on Nov 22, 2025

    build(python): fix `docs` and `docfx` builds (#917)

    eccf448

    chore: rename rst files to avoid conflict with service names (#917)

    5aa76f3

    feat: Added flushes/close functionality to logging handlers (#917)

    4d45b39

    fix: make logging handler close conditional to having the transport o…

    54182c1

    chore(main): release 2.2.2 (#917)

    5d0d003

    feat: Added flushes/close functionality to logging handlers (#917)

    432bf99

    fix: make logging handler close conditional to having the transport o…

    91962c1
  12. parthea
    added a commit that references this issue on Mar 6, 2026

    docs: update docstring for bigquery_create_routine sample (#883) (#917)

    2f07586
  13. parthea
    added a commit that references this issue on Sep 8, 2026

    docs: migrate code from googleapis/python-bigquery (#18303)

    23f9a74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @dhermes
    dhermes

Labels

api: datastoreIssues related to the Datastore API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.