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

expression: fix compatibility issue related to ADDDATE (#13827) #21008

Merged
merged 1 commit into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion expression/builtin_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -2574,7 +2574,7 @@ type baseDateArithmitical struct {

func newDateArighmeticalUtil() baseDateArithmitical {
return baseDateArithmitical{
intervalRegexp: regexp.MustCompile(`[\d]+`),
intervalRegexp: regexp.MustCompile(`-?[\d]+`),
}
}

Expand Down
6 changes: 6 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3796,6 +3796,12 @@ func (s *testIntegrationSuite) TestTimeLiteral(c *C) {
"Warning|1292|Incorrect datetime value: '2008-1-34'"))
}

func (s *testIntegrationSuite) TestIssue13822(c *C) {
tk := testkit.NewTestKitWithInit(c, s.store)
tk.MustQuery("select ADDDATE(20111111, interval '-123' DAY);").Check(testkit.Rows("2011-07-11"))
tk.MustQuery("select SUBDATE(20111111, interval '-123' DAY);").Check(testkit.Rows("2012-03-13"))
}

func (s *testIntegrationSuite) TestTimestampLiteral(c *C) {
defer s.cleanEnv(c)
tk := testkit.NewTestKit(c, s.store)
Expand Down