Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transaction.save does not allow a NULL value. #1081

Closed
krisnye opened this issue Jan 21, 2016 · 2 comments
Closed

Transaction.save does not allow a NULL value. #1081

krisnye opened this issue Jan 21, 2016 · 2 comments
Assignees
Labels
api: datastore Issues related to the Datastore API.

Comments

@krisnye
Copy link

krisnye commented Jan 21, 2016

Null is a perfectly valid value to insert into the datastore and should be supported by this API. Null indicates that the value is not present, but that it still needs to be indexed, and so it is different from simply not having a property which means the entity will not be indexed for that property.

When attempting to save a record with a null value this exception is thrown:

  throw new Error('Unsupported field value, ' + v + ', is provided.');
        ^
Error: Unsupported field value, null, is provided.
    at Object.valueToProperty (gcloud/lib/datastore/entity.js:437:9)
    at gcloud/lib/datastore/request.js:405:29
    at gcloud/lib/datastore/request.js:404:48
    at Transaction.DatastoreRequest.save (gcloud/lib/datastore/request.js:397:12)
    at gcloud/lib/datastore/transaction.js:229:42
    at Transaction.commit_ (gcloud/lib/datastore/transaction.js:225:6)
    at /Users/krisnye/Projects/glass/lib/googlecloud/Dataset.js:343:21
@krisnye
Copy link
Author

krisnye commented Jan 21, 2016

Ok, I found a fix for this, it's incredibly simple. In datastore/entity.js, simply encode a null value as {stringValue:null}

Old code

if (v instanceof String || typeof v === 'string') {
  p.string_value = v;
  return p;
}

New code

if (v == null || v instanceof String || typeof v === 'string') {
  p.string_value = v;
  return p;
}

@stephenplusplus
Copy link
Contributor

Duplicate of #1022. Sadly, we're a bit stuck until the next version of Datastore is released, v1beta3.

@stephenplusplus stephenplusplus added the api: datastore Issues related to the Datastore API. label Jan 21, 2016
sofisl pushed a commit that referenced this issue Jan 17, 2023
* chore: Enable requesting numeric enums in "transport=rest" responses for services supporting this (Java, Go, Python, PHP, TypeScript, C#, and Ruby), even if they do not yet turn on REST transport

chore: disallow "transport=rest" for services where numeric enums are not confirmed to be supported (except in PHP and Java)
PiperOrigin-RevId: 493113566

Source-Link: googleapis/googleapis@758f0d1

Source-Link: googleapis/googleapis-gen@78bd8f0
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNzhiZDhmMDVlMTI3NjM2M2ViMTRlYWU3MGU5MWZlNGJjMjA3MDNhYiJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* feat: Added SuggestConversationSummary RPC
docs: updated go library package

PiperOrigin-RevId: 501862436

Source-Link: googleapis/googleapis@155e0f4

Source-Link: googleapis/googleapis-gen@3051f61
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMzA1MWY2MTdhOTkxYzI3NGM4OGQyNzA2NGU4MDMwOTVlNGVmOWQzOSJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: meredithslota <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the Datastore API.
Projects
None yet
Development

No branches or pull requests

2 participants