Skip to content

[usage] Harden parsing of time from VarChar field #10390

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

Merged
merged 1 commit into from
Jun 2, 2022

Conversation

easyCZ
Copy link
Member

@easyCZ easyCZ commented May 31, 2022

Description

A consequence of using VarChar to store datetimes is that the varchar can be empty as well. This is handled on the TS side as optional but in Go, we need something akin to sql.NullString to handle this case.

This PR extends the VarCharTime struct to handle this case by setting validity and exposes methods to check if the value was set.

Related Issue(s)

Fixes #

How to test

Unit tests

Release Notes

NONE

Documentation

NONE

return nil
case string:
if len(s) == 0 {
n.valid = false
Copy link
Member Author

Choose a reason for hiding this comment

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

We wouldn't necessarily need to do this as false is the default value, but it's here mostly for ease of reading.

@easyCZ easyCZ force-pushed the mp/usage-db-varchartime branch from ae48e03 to 45f1ca4 Compare June 2, 2022 12:40
@geropl geropl self-requested a review June 2, 2022 12:47
Copy link
Member

@geropl geropl left a comment

Choose a reason for hiding this comment

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

Thank you, LGTM!

@roboquat roboquat merged commit b88e77c into main Jun 2, 2022
@roboquat roboquat deleted the mp/usage-db-varchartime branch June 2, 2022 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants