Open someone1 opened 4 years ago
Thanks for your report!
@benwhitehead any thoughts on what we should do with this? Does the noindex tagging in the example look correct to you?
I'm also wondering if it's even worth having the client side validation at https://github.com/googleapis/google-cloud-go/blob/2cf2adb116492d7f7a743c75aa66f774b4aa71c8/datastore/save.go#L386 , if the API will also reject this.
If the api is performing the validation anyway, I'd prefer to defer to it since it is the ultimate authority and can take care of the nestedness and things since it has to store the values anyway.
Wanted to chime in that the package vs API error aside - the issue seems rooted in the fact that nested structs that implement the PropertyLoadSaver
interface lose the noIndex
detail along the way - are there other ramifications to this? Would the API know to ignore the noIndex
option on nested properties where the parent has noIndex: true
defined?
Doing some digging it seems that if a struct implements the PLS interface, then the saveOpts
from the parent aren't propagated through since the package will just call Save without passing the options used by an potential parent like it otherwise would for structs that don't implement the PLS interface.
Would a simple fix be to do something similar to the flatten
property and loop through the returned properties and properly set noIndex
? If so, I could throw up a PR for this!
@tritone @BenWhitehead - I'd be happy to submit a PR with the above implemented - would this be the right approach?
I don't don't have the go knowledge to be able to do the review on my own. I'll defer to @tritone or @crwilcox if they have the bandwidth to help with the review.
Client Datastore v1.3.0
Environment Go 1.13 AppEngine
Go Environment $ go version
$ go env
Code
Expected behavior Logs output "It worked"
Actual behavior Output:
Additional context
Removing the PropertyLoadSaver implementation from
B
will work as expected, where the parentnoindex
option applies to the nested fields, despite their lack of thenoindex
option.This only seems to affect nested structs, if I added
noindex
toB.Value
and tried to savem.B[0]
in the example above, it would not enforce the max length despite implementing thePropertyLoadSaver
interface.