-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
expression: fix date_add interval month,year diffs from mysql #8988
Conversation
Codecov Report
@@ Coverage Diff @@
## master #8988 +/- ##
==========================================
- Coverage 67.26% 67.26% -0.01%
==========================================
Files 371 371
Lines 77161 77182 +21
==========================================
+ Hits 51905 51916 +11
- Misses 20620 20633 +13
+ Partials 4636 4633 -3
Continue to review full report at Codecov.
|
/run-all-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.
Rest LGTM
expression/builtin_time.go
Outdated
goTime = goTime.AddDate(int(year), int(month), int(day)) | ||
// when we execute select date_add('2018-01-31',interval 1 month) in mysql we got 2018-02-28 | ||
// but in tidb we got 2018-03-03 | ||
// dig it and we found it's caused by golang api time.DateDate(year int, month Month, day, hour, min, sec, nsec int, loc *Location) Time , |
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.
Please uppercase the first letter of each comment sentence.
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.
@imtbkcat PTAL
uppercase the first letter of each comment sentence.
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.
LGTM
expression/builtin_time.go
Outdated
goTime = goTime.AddDate(int(year), int(month), int(day)) | ||
// When we execute select date_add('2018-01-31',interval 1 month) in mysql we got 2018-02-28 | ||
// but in tidb we got 2018-03-03. | ||
// Dig it and we found it's caused by golang api time.DateDate(year int, month Month, day, hour, min, sec, nsec int, loc *Location) Time , |
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.
s/time.DateDate/time.Date
expression/builtin_time.go
Outdated
// Dig it and we found it's caused by golang api time.DateDate(year int, month Month, day, hour, min, sec, nsec int, loc *Location) Time , | ||
// it says October 32 converts to November 1 ,it conflits with mysql. | ||
// See https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_date-add | ||
df := getFixDays(int(year), int(month), int(day), goTime) |
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.
It's better to wrap these to a more easy-to-use function like dateAdd(goTime, year, month, day) goTime
?
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've modified as you suggested.
PTAL @qw4990
LGTM |
@haplone Thanks for your contribution~ Can you help us to cherry pick this commit to release-2.1 and release-2.0? |
What problem does this PR solve?
date_add interval month diffs from mysql
when we execute select date_add('2018-01-31',interval 1 month) in mysql we got 2018-02-28
but in tidb we got 2018-03-03
What is changed and how it works?
Check List
Tests