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: Add ARRAY support #19

Merged
merged 17 commits into from
Aug 2, 2021
Merged

feat: Add ARRAY support #19

merged 17 commits into from
Aug 2, 2021

Conversation

olavloite
Copy link
Collaborator

@olavloite olavloite commented Jul 28, 2021

Should not be merged before #10 (or should be merged instead of #10, as they both contain the same changes).

  • Adds support ARRAY data type.
  • Adds GitHub Actions configuration for running unit tests during pre-submits.
  • Adds the mock server from the Go client library so it is no longer depending on internal test code.

@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Jul 28, 2021
@olavloite olavloite marked this pull request as ready for review August 1, 2021 09:16
@hengfengli
Copy link
Collaborator

@olavloite Can we rebase this PR so that it can be easier for reviewing?

@olavloite
Copy link
Collaborator Author

@olavloite Can we rebase this PR so that it can be easier for reviewing?

Certainly, it should now be rebased and without conflicts.

case sppb.TypeCode_NUMERIC:
var v spanner.NullNumeric
if err := col.Decode(&v); err != nil {
return err
}
dest[i] = v.Numeric
dest[i] = v
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add if v.Valid?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I can see the confusion here. I've add a comment for why we are assigning v here in all cases (that is; also when v.Valid is false). The reason that we do so for NUMERIC and DATE data types is that the Go sql package does not have a native type mapping for these types. That means that if we were to return nil here, Go sql would not correctly understand what type it is. So instead we return a NullNumeric or NullDate in these cases.
The reason we don't do that for for example INT64 is that the Go sql package natively maps the Spanner INT64 data type to the Go int64 type, and so we should return nil in those cases.

} else {
dest[i] = v.Date.In(time.UTC) // TODO(jbd): Add note about this.
}
dest[i] = v
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See above

Copy link
Collaborator

@hengfengli hengfengli left a comment

Choose a reason for hiding this comment

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

LGTM.

@olavloite olavloite merged commit 6b1556a into googleapis:main Aug 2, 2021
@olavloite olavloite deleted the arrays branch August 2, 2021 06:00
@olavloite olavloite mentioned this pull request Aug 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants