Skip to content

Datastore Query with Key filter failing on GCE #1639

Closed
@ndenny

Description

@ndenny

Since I upgraded to 0.11.0, I'm seeing a problem with my production environment on GCE, but not when I run it locally.

I am trying to query the datastore, using a filter on a property that is a Key. I have example code below - the basic problem is that when using the filter, I get no results back, even when querying using a key I know exists.

Looking at the print statements, the difference between my local and GCE environments appears to be that the key I create myself has project=project_id whereas the query returns a key with project=s~project_id.

Environment: GCE, Python 2.7.9, gcloud 0.11.0 [following code asserts with no results returned from 2nd query]
Local: Mac OS X, Python 2.7.10, gcloud 0.11.0 [following code works]

from gcloud import datastore

def main():
    client = datastore.Client()

    last_result = None
    query = client.query(kind='Foo')
    results = query.fetch(1)
    for result in results:
        last_result = result
    assert last_result is not None

    query2 = client.query(kind='Foo')
    key = client.key('Bar', last_result['bar'].id)
    print key
    print last_result['bar']
    query2.add_filter('bar', '=', key)
    results = query2.fetch(1)
    assert len(list(results)) > 0

if __name__ == '__main__':
    main()

Metadata

Metadata

Assignees

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