Open git-hulk opened 2 years ago
@rahul2393 I can try to handle this if you have no time to do it recently.
@git-hulk
[]CustomType
is already supported if it implements spanner.Encoder
interface. You can follow the below linked sample code to use the functionality.
Sample code
@harshachinta sure, many thanks for your help, will try it soon.
@harshachinta sure, many thanks for your help, will try it soon.
@harshachinta I got what you mean after looking at the sample code, but it's a bit trivial to implement a struct for all custom types, it'd be better can support the custom type slice directly.
@harshachinta I got what you mean after looking at the sample code, but it's a bit trivial to implement a struct for all custom types, it'd be better can support the custom type slice directly.
@git-hulk Do you mean you don't want to implement spanner.encoder
interface? Instead treat []CustomType
as array of struct
?
Can you provide a sample code of what you are trying to do and what is the error you are facing? Also provide what is the output you are expecting for that case. It would help us better understand the usecase.
Hi @harshachinta
@git-hulk Do you mean you don't want to implement spanner.encoder interface? Instead treat []CustomType as array of struct?
What I want is []CustomType can also be encoded if the CustomType has implemented the spanner.encoder
like spanner.NullString.
Is your feature request related to a problem? Please describe. We are using the custom type like
NullString
but the array custom type[]CustomType
since it's NOT in the allow types: https://github.com/googleapis/google-cloud-go/blob/7934007d92dd119539f128974571dd24259afad9/spanner/value.go#L3865Does it make sense to support encoding the custom type array like
spanner.NullString
.Describe the solution you'd like
Can encode
[]CustomType
if CustomType implemented thespanner.Encoder
.