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
spanner: Can not decode Null value to user defined custom type with DecodeSpanner #4552
Comments
@olavloite Can you please take a look at this issue? Thanks. |
Allow NULL values from the database to be passed in to the DecodeSpanner method of a struct that implements spanner.Decoder. Fixes #4552
Allow NULL values from the database to be passed in to the DecodeSpanner method of a struct that implements spanner.Decoder. Fixes #4552
Allow NULL values from the database to be passed in to the DecodeSpanner method of a struct that implements spanner.Decoder. Fixes #4552
@hengfengli @olavloite Thanks for the quick fix. Can you share the reasons for restrict the type that can be decoded by |
I'm not exactly sure what you mean in this case. Do you mean the restriction before this change? If so, I think the restriction was simply an accidental omission by the original author that did not realize that null values needed special handling. |
@NeoCN Do you mean why we limit to |
@hengfengli @olavloite Got it, thanks guys. |
@hengfengli When will the new spanner package version with this bugfix be released ? |
I can do a patch release (1.24.1) today. |
Client
Spanner
Environment
macOS
Go Environment
$ go version
go version go1.16.6 darwin/amd64
$ go env
Code
https://github.com/googleapis/google-cloud-go/blob/v0.90.0/spanner/value.go#L1330-L1338
https://github.com/googleapis/google-cloud-go/blob/v0.90.0/spanner/value.go#L1911-L1923
Expected behavior
With user defined custom type that implements spanner.Decoder interface, how the Null value is handled can be defined in the
DecodeSpanner
function, and the expected behavior is thatDecodeSpanner
function is invoked when decode Null value.Actual behavior
As the code logic listed,
getGenericValue
function will return error when the value type is notNumber
,Bool
,String
.And when the value is Null, the value type is
*structpb.Value_NullValue
, an error returned, so theDecodeSpanner
in custom type will not be invoked and an error returned.The text was updated successfully, but these errors were encountered: