From f0e6e6457f352aca6395df26b860996d61482787 Mon Sep 17 00:00:00 2001 From: pingcap-github-bot Date: Fri, 10 Apr 2020 14:22:39 +0800 Subject: [PATCH] types: fix parse date inconsistent with MySQL (#14405) (#16242) --- types/time.go | 4 +--- types/time_test.go | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/types/time.go b/types/time.go index 6547eebd65191..f9e4d9e68ca2a 100644 --- a/types/time.go +++ b/types/time.go @@ -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) } diff --git a/types/time_test.go b/types/time_test.go index 5a00a4dca0f7f..01ba8f7710883 100644 --- a/types/time_test.go +++ b/types/time_test.go @@ -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", @@ -177,6 +179,8 @@ func (s *testTimeSuite) TestDate(c *C) { errTable := []string{ "0121231", + "1201012736.0000", + "1201012736", "2019.01", }