Skip to content

Commit

Permalink
types: fix parse date inconsistent with MySQL (#14405) (#16242)
Browse files Browse the repository at this point in the history
  • Loading branch information
sre-bot authored Apr 10, 2020
1 parent f03ea0f commit f0e6e64
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 1 addition & 3 deletions types/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,8 @@ func (t *Time) check(sc *stmtctx.StatementContext) error {
switch t.Type {
case mysql.TypeTimestamp:
err = checkTimestampType(sc, t.Time)
case mysql.TypeDatetime:
case mysql.TypeDatetime, mysql.TypeDate:
err = checkDatetimeType(t.Time, allowZeroInDate, allowInvalidDate)
case mysql.TypeDate:
err = checkDateType(t.Time, allowZeroInDate, allowInvalidDate)
}
return errors.Trace(err)
}
Expand Down
4 changes: 4 additions & 0 deletions types/time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ func (s *testTimeSuite) TestDateTime(c *C) {
errTable := []string{
"1000-01-01 00:00:70",
"1000-13-00 00:00:00",
"1201012736.0000",
"1201012736",
"10000-01-01 00:00:00",
"1000-09-31 00:00:00",
"1001-02-29 00:00:00",
Expand Down Expand Up @@ -177,6 +179,8 @@ func (s *testTimeSuite) TestDate(c *C) {

errTable := []string{
"0121231",
"1201012736.0000",
"1201012736",
"2019.01",
}

Expand Down

0 comments on commit f0e6e64

Please sign in to comment.