Skip to content

Key IDs Are Coming Back with String Values #2093

@husafan

Description

@husafan

Environment details

  • OS: OS X
  • Node.js version: 6.6.0
  • npm version: 3.10.3
  • google-cloud-node version:
    "@google-cloud/datastore": "^0.7.0",
    "@google-cloud/storage": "^0.6.0",

Steps to reproduce

  1. require google-cloud
  2. Create an entity in the datastore with an auto-generated long ID.
      let key = this._datastore.key(['SomeEntity']);
      let dsEntity = {
        key: key,
        data: {...},
      };
      this._datastore.upsert(dsEntity).then...
  1. Run a query that would fetch the entity:
      this._datastore.runQuery(query).then((response) => {
      let entities = response[0];
      let results = [];
      entities.forEach((entity) => {
        const resolved = {
          key: entity[Datastore.KEY], // <-- THIS KEY.ID IS NOW A STRING
          data: entity,
        };

4 Attempt to fetch the entity identified by the key returned in step 3.

       this._datastore.get(resolved.key) // <-- THIS WILL FAIL BECAUSE ID IS A STRING

We believe this is related to #1413, specifically, https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2FGoogleCloudPlatform%2Fgoogle-cloud-node%2Fcommit%2Fbab982faba1c6ef3c393da816535be3704113787&sa=D&sntz=1&usg=AFQjCNGTKOrx2uKSEd7TrDMwbFqat44fVw

Metadata

Metadata

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