-
Notifications
You must be signed in to change notification settings - Fork 1.5k
datastore: equal keys in different namespaces are deduped incorrectly #7829
Copy link
Copy link
Closed
Labels
api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Client
Datastore
Environment
Any...
Go Environment
$ go version
go version go1.20.3 darwin/arm64
$ go env
Code
google-cloud-go/datastore/datastore.go
Lines 459 to 463 in e41aae2
| ks := k.String() | |
| if _, ok := keyMap[ks]; !ok { | |
| pbKeys = append(pbKeys, keyToProto(k)) | |
| } | |
| keyMap[ks] = append(keyMap[ks], i) |
Let's say I have...
- Entity 1:
Kind: A, Name: B, Namespace: NS1 - Entity 2:
Kind: A, Name: B, Namespace: NS2
...then the second one will be deduped in the code above since namespace is not taken into consideration. Meaning that pbKeys is not complete.
Expected behavior
Both keys should be added to pbKeys.
Actual behavior
As one can see above. Index 1 and 2 in keys are just index 1 in pbKeys due to the fact that they share the same string representation.
Additional context
N/A
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

