Skip to content

Commit e151ce4

Browse files
committed
impl flexible Eval()
1 parent 8c4c708 commit e151ce4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

sql/expression/enum.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,15 @@ func (e *EnumToString) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)
6969
}
7070

7171
enumType := e.Enum.Type().(types.EnumType)
72-
str, _ := enumType.At(int(val.(uint16)))
72+
var str string
73+
switch v := val.(type) {
74+
case uint16:
75+
str, _ = enumType.At(int(v))
76+
case string:
77+
str = v
78+
default:
79+
return nil, sql.ErrInvalidType.New(val, types.Text)
80+
}
7381
return str, nil
7482
}
7583

0 commit comments

Comments
 (0)