Skip to content

Commit fb1f8d6

Browse files
committed
rm extra changes
1 parent 3d587cb commit fb1f8d6

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

sql/expression/enum.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (e *EnumToString) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)
8080
case string:
8181
str = v
8282
default:
83-
return nil, sql.ErrInvalidType.New(types.Text.String())
83+
return nil, sql.ErrInvalidType.New(val, types.Text)
8484
}
8585
return str, nil
8686
}

sql/types/enum.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,13 @@ func (t EnumType) Convert(ctx context.Context, v interface{}) (interface{}, sql.
165165

166166
switch value := v.(type) {
167167
case int:
168-
if _, ok := t.At(value); ok {
169-
return uint16(value), sql.InRange, nil
170-
}
171168
// MySQL rejects 0 values in strict mode regardless of enum definition
172169
if value == 0 && t.validateScrictMode(ctx) {
173170
return nil, sql.OutOfRange, ErrConvertingToEnum.New(value)
174171
}
172+
if _, ok := t.At(value); ok {
173+
return uint16(value), sql.InRange, nil
174+
}
175175
case uint:
176176
return t.Convert(ctx, int(value))
177177
case int8:
@@ -224,7 +224,6 @@ func (t EnumType) validateScrictMode(ctx context.Context) bool {
224224
return false
225225
}
226226

227-
228227
// Equals implements the Type interface.
229228
func (t EnumType) Equals(otherType sql.Type) bool {
230229
if ot, ok := otherType.(EnumType); ok && t.collation.Equals(ot.collation) && len(t.idxToVal) == len(ot.idxToVal) {

0 commit comments

Comments
 (0)