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

fix(datastore): Handling nil slices in save and query #8043

Merged
merged 3 commits into from
Jun 12, 2023

Conversation

bhshkh
Copy link
Contributor

@bhshkh bhshkh commented Jun 4, 2023

Issue: #5760
Cause:
If an entity e.g. {'Description': 'Buy milk'} is being queried into a struct e.g. task := Task{Description: "Some description", Done: false, Slice: []int{11, 12, 13, 14, 15}}, then the fields not existing in entity retrieved from datastore are left untouched i.e. it.Next(&task) will populate task variable to Task{Description: "Buy milk", Done: false, Slice: []int{11, 12, 13, 14, 15}}

Any nil slice property in put call to datastore gets ignored i.e. as if the property does not exist for that entity. So, while retrieving nil slices, they don't get populated in the struct.

Fix: Write nil slices as null values to datastore similar to nodejs and python client libraries. Special handling for nil slices while querying datastore.

@bhshkh bhshkh requested review from a team as code owners June 4, 2023 19:51
@product-auto-label product-auto-label bot added the size: s Pull request size is small. label Jun 4, 2023
@bhshkh bhshkh requested a review from enocom June 6, 2023 07:28
@bhshkh bhshkh enabled auto-merge (squash) June 10, 2023 02:34
@bhshkh bhshkh changed the title fix(datstore): Handling nil slices in save and query fix(datastore): Handling nil slices in save and query Jun 10, 2023
@bhshkh bhshkh merged commit 36f01e9 into googleapis:main Jun 12, 2023
7 checks passed
bhshkh added a commit to bhshkh/google-cloud-go that referenced this pull request Jun 13, 2023
bhshkh added a commit that referenced this pull request Jun 13, 2023
xwkuang5 pushed a commit to xwkuang5/google-cloud-go that referenced this pull request Jun 13, 2023
…nto agg-add-trace

* 'agg-add-trace' of github.com:xwkuang5/google-cloud-go:
  Fix formating.
  chore(firestore): Add bloom filter related comments (googleapis#8079)
  fix(firestore): Cleanup integration test resources (googleapis#8057)
  fix(datastore): Handling nil slices in save and query (googleapis#8043)
@bhshkh bhshkh deleted the datastore-nil-slices branch June 22, 2023 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

datastore: Previous value is returned for overwritten key when dst not zero-valued
3 participants