Skip to content

Commit

Permalink
Fix last_day function (#9746)
Browse files Browse the repository at this point in the history
  • Loading branch information
wjhuang2016 authored and qw4990 committed Mar 15, 2019
1 parent 0618339 commit 9187e3d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion expression/builtin_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -5641,7 +5641,7 @@ func (b *builtinLastDaySig) evalTime(row chunk.Row) (types.Time, bool, error) {
tm := arg.Time
var day int
year, month := tm.Year(), tm.Month()
if year == 0 && month == 0 && tm.Day() == 0 {
if month == 0 {
return types.Time{}, true, handleInvalidTimeError(b.ctx, types.ErrIncorrectDatetimeValue.GenWithStackByArgs(arg.String()))
}
day = types.GetLastDay(year, month)
Expand Down
2 changes: 2 additions & 0 deletions expression/builtin_time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2428,6 +2428,8 @@ func (s *testEvaluatorSuite) TestLastDay(c *C) {
"0000-00-00",
"1992-13-00",
"2007-10-07 23:59:61",
"2005-00-00",
"2005-00-01",
123456789}

for _, i := range testsNull {
Expand Down

0 comments on commit 9187e3d

Please sign in to comment.