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
DATETIME handling & microsecond support #26
Conversation
d1bb132
to
ba8b48a
Compare
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.
LG, just a couple comments
// | ||
// https://github.com/MariaDB/server/blob/mysql-5.5.36/sql-common/my_time.c#L124 | ||
var DatetimeLayouts = []string{ | ||
"2006-01-02", |
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 would include the main constant in this slice, then just loop over it a single time
sql/type.go
Outdated
@@ -731,7 +743,18 @@ func (t datetimeT) Convert(v interface{}) (interface{}, error) { | |||
case string: | |||
t, err := time.Parse(DatetimeLayout, value) |
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.
This is a little convoluted. Better to loop over the accepted layouts a single time, returning as soon as you find one that parses.
sql/type.go
Outdated
} | ||
|
||
if failed { | ||
return nil, ErrConvertingToTime.Wrap(err, v) |
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.
This wrapped error is no longer applicable (it will give the false impression that the last format attempted is the only correct one)
I copied the logic from the Timestamps section lol. I’ll add these adjustments there as well. |
… in parsing Signed-off-by: Daylon Wilkins <daylon@liquidata.co>
ba8b48a
to
c4ad10a
Compare
No description provided.