-
Notifications
You must be signed in to change notification settings - Fork 991
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
time column type string formatting and test coverage #891
time column type string formatting and test coverage #891
Conversation
mysql/util_test.go
Outdated
} | ||
|
||
for _, test := range tests { | ||
|
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.
mysql/util_test.go:42:30: unnecessary leading newline (whitespace)
from CI ⬆️
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.
rest lgtm. Thank you!
mysql/util_test.go
Outdated
for _, test := range tests { | ||
n := len(test.Data) | ||
|
||
// binary.LittleEndian.PutUint32(data[1:], uint64(test.Seconds)) |
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 can remove this comment?
mysql/util_test.go
Outdated
got, err := FormatBinaryTime(n, test.Data) | ||
if test.Error { | ||
require.Error(t, err) | ||
} else if err != nil { |
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 can use
... else {
require.NoError(t. err)
}
here
This is past the latest tagged release version of `v1.8.0` because we need go-mysql-org/go-mysql#891 which fixed a bug with zero-valued `time` columns when using prepared statements. If/when a new version is tagged we can move to that, the only reason we're naming a specific commit is because it's the current HEAD of that repository.
This is past the latest tagged release version of `v1.8.0` because we need go-mysql-org/go-mysql#891 which fixed a bug with zero-valued `time` columns when using prepared statements. If/when a new version is tagged we can move to that, the only reason we're naming a specific commit is because it's the current HEAD of that repository.
This is past the latest tagged release version of `v1.8.0` because we need go-mysql-org/go-mysql#891 which fixed a bug with zero-valued `time` columns when using prepared statements. If/when a new version is tagged we can move to that, the only reason we're naming a specific commit is because it's the current HEAD of that repository.
This is past the latest tagged release version of `v1.8.0` because we need go-mysql-org/go-mysql#891 which fixed a bug with zero-valued `time` columns when using prepared statements. If/when a new version is tagged we can move to that, the only reason we're naming a specific commit is because it's the current HEAD of that repository.
This PR improves the string formatting of time type columns,
FormatBinaryTime
does not return properly formatted time strings in all cases.In the zero value case, it was incorrectly returning a
date
formatted string instead of the expected zerotime
of00:00:00
. For positive times there was a leading null byte in the returned []byte.CREATE TABLE time_test (ts TIME);
INSERT INTO time_test (ts) VALUES ("00:00:00"), ("06:12:10");
Reading the values out (using a statement as direct queries don't use FormatBinaryTime)
SELECT * FROM %s WHERE ts > ?
with query parameter
-5
or some other numberresulted in
when the expected result is