Skip to content

datastore: Projection KeyOnly-Query unable to select __key__ - property stay empty #2338

@aweiher

Description

@aweiher

Hello,

I try a really basic query, selecting the __key__ property - but it stays empty.

I searched the issues and stackoverflow, I also created a thread a SO, but it stays unanswered. I also created a ticket at the google cloud support, also no answer yet. Therefore I create this issue now.

Thread on stackoverflow:

Environment details

  • OS: Linux (Ubuntu 16.04.1 LTS)
  • Node.js version: v7.3.0
  • npm version: 3.10.10
  • google-cloud-node version: 1.0.2

Steps to reproduce

const datastore = require('@google-cloud/datastore')({
  projectId: project,
  keyFilename: `key.json`
});

const query = datastore.createQuery("Projects").select('__key__');

datastore.runQuery(query, (err, entities, info) => {
  console.log('RESULTS:', {err, entities, info});
});

Result:

RESULTS: { err: null,
  entities: [ {}, {}, {}, {} ],
  info: 
   { moreResults: 'NO_MORE_RESULTS',
     endCursor: 'CjwSNmoOZX5zYW0tcmVjb3JkZXJyJAsSHF9BRV9EYXRhc3RvcmVBZG1pbl9PcGVyYXRpb24YwYQ9DBgAIAA=' } }

Expected Result:

RESULTS: { err: null,
  entities: [ 
      {___key___: 5634472569470976}, 
      {___key___: 5639445604728832}, 
      {___key___: 5654313976201216}, 
      {___key___: 5659313586569216} 
      ],
  info: 
   { moreResults: 'NO_MORE_RESULTS',
     endCursor: 'CjwSNmoOZX5zYW0tcmVjb3JkZXJyJAsSHF9BRV9EYXRhc3RvcmVBZG1pbl9PcGVyYXRpb24YwYQ9DBgAIAA=' } }

The property __key__ stays empty and I dont know why. Selecting an other property works as expected.

It should work as it is described in the API Docs: https://cloud.google.com/datastore/docs/concepts/queries#projection_queries

Do I missing something?

Thanks!

Metadata

Metadata

Assignees

Labels

api: datastoreIssues related to the Datastore API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions