-
Notifications
You must be signed in to change notification settings - Fork 2.3k
make the NullTime type an alias of sql.NullTime #1049
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
make the NullTime type an alias of sql.NullTime #1049
Conversation
Something seems to be broken with Go13+ (see Travis):
|
case time.Time: | ||
nt.Time, nt.Valid = v, true | ||
return | ||
case []byte: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parseDateTime
for []byte
and string
are still required, even with sql.NullTime in Go 1.3+.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is misuse of mysqlNullTime, users should add the parseTime=true
option.
because parseDateTime
does not consider timezones.
TestLegacyNullTime
and TestNullTime
are working examples.
but, you know, it may break existing codes. I'm thinking about it now... 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should at least not push it right before a release. Let's reconsider this later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree
You probably don't need that much this change for your migration path. Here is a simple workaround: a type cast, because the representations are now the same.
|
close this because this pull request breaks the compatibility, and it is enough to add a deprecated message into |
Description
updates #960
currently, the following code will fails because of type miss match.
It may prevent migrating from
mysql.NullTime
tosql.NullTime
.From Go 1.9, Go supports type aliases. https://golang.org/doc/go1.9#language
It helps migrating.
Checklist