fix(datastore): Correcting string representation of Key#8363
Merged
bhshkh merged 3 commits intogoogleapis:mainfrom Aug 8, 2023
Merged
fix(datastore): Correcting string representation of Key#8363bhshkh merged 3 commits intogoogleapis:mainfrom
bhshkh merged 3 commits intogoogleapis:mainfrom
Conversation
enocom
reviewed
Aug 3, 2023
Contributor
enocom
left a comment
There was a problem hiding this comment.
Could we add a description to each test case to explain what it's testing. As written, this test requires careful study to understand what it's doing.
Contributor
Author
Done |
kolea2
approved these changes
Aug 8, 2023
sgp
added a commit
to sgp/google-cloud-go
that referenced
this pull request
Sep 5, 2024
…#10684) fix(datastore): remove namespace from Key.String() Fixes googleapis#10684. Datastore namespaces may be sensitive, and it's best not to emit them. Restores the behavior of `Key.String` prior to googleapis#8363, but maintains the fix for googleapis#7829 by providing an internal implementation that does provide the namespace.
bhshkh
pushed a commit
that referenced
this pull request
Sep 5, 2024
* fix(datastore): remove namespace from Key.String() (#10684) Datastore namespaces may be sensitive, and it's best not to emit them. Provide a `datastore.Key.StringWithNamespace()` as an alternative, and use this version internally, which preserves the fix from #7829. * amend! fix(datastore): remove namespace from Key.String() (#10684) fix(datastore): remove namespace from Key.String() Fixes #10684. Datastore namespaces may be sensitive, and it's best not to emit them. Restores the behavior of `Key.String` prior to #8363, but maintains the fix for #7829 by providing an internal implementation that does provide the namespace.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue: While getting entities from Datastore, if the queried keys have same Kind and name/ID but different namespaces, then only one of the entities get retrieved
Cause: When entities are returned from Datastore in LookupResponse, they are not in the order in which the Keys are sent. E.g. If keys sent were:{ {kind, name1, namespace1}, {kind, name2, namespace1 }, {kind, name3, namespace1 }}, The response can be {entity3, entity1, entity2} instead of {entity1, entity2, entity3}.
To make it easier for users to consume, the library arranges the entities in the order of keys before returning them to user.
To do this, all the keys are reverse mapped to their index in the input array and then the entities received from Datastore are put at the index of the input keys in the response array. For above example, the map created is {"kind,name1": 0, "kind, name2": 1, "kind,name3": 2}. As can be seen here, the keys in the map do not take into account the namespace. So, if 2 keys have different namespaces the entities response gets overwritten.
Fix: Add namespace to key in the reverse map