Skip to content
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

feat(spanner): enable row.ToStructLenient to work with STRUCT data type #5944

Merged
merged 4 commits into from Apr 27, 2022

Conversation

rahul2393
Copy link
Contributor

Fixes: #5938

@rahul2393 rahul2393 requested review from a team as code owners April 26, 2022 08:46
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: spanner Issues related to the Spanner API. labels Apr 26, 2022
@rahul2393 rahul2393 requested review from olavloite and codyoss and removed request for codyoss April 26, 2022 08:47
spanner/value.go Outdated
@@ -986,7 +986,7 @@ func parseNullTime(v *proto3.Value, p *NullTime, code sppb.TypeCode, isNull bool

// decodeValue decodes a protobuf Value into a pointer to a Go value, as
// specified by sppb.Type.
func decodeValue(v *proto3.Value, t *sppb.Type, ptr interface{}) error {
func decodeValue(v *proto3.Value, t *sppb.Type, ptr interface{}, opts ...bool) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it maybe be better to create a decodeValueOption interface and pass that in instead of booleans? This means that we can only have boolean options, which both limit the types of options that we can have, but also makes them very 'magical'. Imagine that we support 3 options; no-one will understand what decodeValue(v, t, true, false, false) means.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, updated the PR please take a look again.

spanner/value.go Outdated
@@ -3043,6 +3049,22 @@ func errDecodeStructField(ty *sppb.StructType, f string, err error) error {
return se
}

// DecodeSetting contains all the settings for decoding from spanner struct
type DecodeSetting struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think we can make this unexported

@rahul2393 rahul2393 merged commit bca8d50 into main Apr 27, 2022
@rahul2393 rahul2393 deleted the lenient-struct-arrray-decode branch April 27, 2022 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the Spanner API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

spanner: row.ToStructLenient doesn't work for STRUCT data type
2 participants