diff --git a/types/time.go b/types/time.go index 206a6541b3d19..9227311bdceca 100644 --- a/types/time.go +++ b/types/time.go @@ -671,10 +671,8 @@ func (t *Time) check(sc *stmtctx.StatementContext) error { switch t.tp { 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 bf583447dba60..a3060f8302d74 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", }