Skip to content

Commit 1c9d6d9

Browse files
committed
Fix INSERT IGNORE enum zero handling in strict mode
Allow uint16 enum indices to be converted without strict mode validation. This fixes INSERT IGNORE behavior where stored uint16(0) values should display as empty strings, matching MySQL behavior exactly. Resolves the (unknown) error during SELECT after INSERT IGNORE.
1 parent 57d1bbb commit 1c9d6d9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sql/types/enum.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,10 @@ func (t EnumType) Convert(ctx context.Context, v interface{}) (interface{}, sql.
182182
case int16:
183183
return t.Convert(ctx, int(value))
184184
case uint16:
185-
return t.Convert(ctx, int(value))
185+
// uint16 values are stored enum indices - allow them without strict mode validation
186+
if _, ok := t.At(int(value)); ok {
187+
return value, sql.InRange, nil
188+
}
186189
case int32:
187190
return t.Convert(ctx, int(value))
188191
case uint32:

0 commit comments

Comments
 (0)