Skip to content

Ancestor query with filter on children not returning anything #1237

@susanlinsfu

Description

@susanlinsfu

I am using gcloud-node v.0.30.3 and since it doesn't support gRPC I am using gcd-rpc for my local datastore.

Say I run this query to get all the children:

        var query = datastore.createQuery('Contacts').hasAncestor(datastore.key(['ContactsParent', 'my_username']));
            datastore.runQuery(query, function (err, entities) {
            if (err) {
                console.log('error ' + err);
                return;
            }
            console.log(JSON.stringify(entities));
                return;
        });

This works and returns all the entities. If I go:

        var query = datastore.createQuery('Contacts').hasAncestor(datastore.key(['ContactsParent', 'my_username'])).filter('status', 'some status');
            datastore.runQuery(query, function (err, entities) {
            if (err) {
                console.log('error ' + err);
                return;
            }
            console.log(JSON.stringify(entities));
                return;
        });

Nothing is return even though it should return something. Nothing is printed in the node console.

I have noticed some strange behavior. If I add a limit clause to this query it will return an empty array ( [] is printed in the console), but without it nothing.

My index.yaml file looks like this:

indexes: - kind: Contacts ancestor: yes properties: - name: status

I am expecting with this query that all the children get returned, and then from those children only the ones with a status of 'some status' return. This is not happening.

The records do exist in the datastore, but when I filter they do not. Example of a record:

datastore.save(
            {
              key: datastore.key(['ContactsParent','my_username', 'Contacts','my_contact']),
              method: 'insert',
              data: {
                status: 'some status'
              }
            }
}

Metadata

Metadata

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