-
-
Notifications
You must be signed in to change notification settings - Fork 238
fix case insensitivity and return type for str_to_date
#2839
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
Conversation
…ysql-server into james/str-date-case
…ysql-server into james/str-date-case
fulghum
left a comment
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.
Looks good! Just a couple minor comments and then a question about some of the error test queries.
| {"no_day", "Jan 2000", "%b %y", "2020-01-00", ""}, | ||
| {"day_of_month_and_day_of_year", "Jan 3, 100 2000", "%b %e, %j %y", "2020-04-09", ""}, | ||
| {"no_year", "Jan 3", "%b %e", time.Date(0, time.January, 3, 0, 0, 0, 0, time.UTC), ""}, | ||
| {"no_day", "Jan 2000", "%b %y", time.Date(2019, time.December, 31, 0, 0, 0, 0, time.UTC), ""}, |
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 one confused me... shouldn't we return Jan 2000, instead of Dec 31st, 2019?
When I tested this one on MySQL (version 9.0.1 at least, we may want to follow 8.4's behavior, but I didn't have that running currently), I got NULL for this query and the previous query.
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 believe that the test was a incorrect. It should be %Y instead of %y (the test right after is also wrong for the same reason). After that, I think it's some weirdness with the golang time package. There's no 0 day, so it just goes back to the previous year. Additionally, SQL_MODE needs to include NO_ZERO_IN_DATE and NO_ZERO_DATE to have those be NULL, but we don't support either of those in dolt.
Oddly, it seems like time.Date(1999, time.December, 31...) == time.Date(2000, time.January, 0, ...)
str_to_date
This PR fixes an issue with the
str_to_datefunction where we wouldn't match string literals in the date with literals in the format, because we were improperly converting them to lowercase.Additionally, this PR has it so the
str_to_datefunction returns atime.Timeinstead of a string. This gets us closer to MySQL behavior over the server.fixes: dolthub/dolt#8807