Skip to content

Commit 76cb5d0

Browse files
committed
fix monthname
1 parent 9a812be commit 76cb5d0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sql/expression/function/time.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,11 +1455,16 @@ func (*MonthName) CollationCoercibility(ctx *sql.Context) (collation sql.Collati
14551455
func (d *MonthName) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
14561456
val, err := d.EvalChild(ctx, row)
14571457
if err != nil {
1458-
return nil, err
1458+
ctx.Warn(1292, "%s", types.ErrConvertingToTime.New(val).Error())
1459+
return nil, nil
14591460
}
14601461

14611462
switch v := val.(type) {
14621463
case time.Time:
1464+
if v.Equal(types.ZeroTime) {
1465+
ctx.Warn(1292, "%s", types.ErrConvertingToTime.New(val).Error())
1466+
return nil, nil
1467+
}
14631468
return v.Month().String(), nil
14641469
case nil:
14651470
return nil, nil

0 commit comments

Comments
 (0)