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

DATETIME handling & microsecond support #26

Merged
merged 1 commit into from Nov 13, 2019
Merged

Conversation

Hydrocharged
Copy link
Contributor

No description provided.

Copy link
Member

@zachmu zachmu left a 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",
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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)

@Hydrocharged
Copy link
Contributor Author

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>
@Hydrocharged Hydrocharged merged commit 4c6a7a7 into ld-master Nov 13, 2019
@Hydrocharged Hydrocharged deleted the daylon/date-parse branch November 13, 2019 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants