diff --git a/lib/mysql/schema/convert.go b/lib/mysql/schema/convert.go index a7e34e2f..4b01b33f 100644 --- a/lib/mysql/schema/convert.go +++ b/lib/mysql/schema/convert.go @@ -141,12 +141,14 @@ func ConvertValue(value any, colType DataType, opts *Opts) (any, error) { } return value, nil case Binary, Varbinary, Blob: - // Types we expect as a byte array - _, ok := value.([]byte) - if !ok { - return nil, fmt.Errorf("expected []byte got %T for value: %v", value, value) + switch castedValue := value.(type) { + case string: + return []byte(castedValue), nil + case []byte: + return castedValue, nil + default: + return nil, fmt.Errorf("expected []byte or string got %T for value: %v", value, value) } - return value, nil case Date: // MySQL supports 0000-00-00 for dates so we can't use time.Time return asString(value) diff --git a/lib/mysql/schema/convert_test.go b/lib/mysql/schema/convert_test.go index e5e64c57..5bd71100 100644 --- a/lib/mysql/schema/convert_test.go +++ b/lib/mysql/schema/convert_test.go @@ -232,8 +232,8 @@ func TestConvertValue(t *testing.T) { { name: "binary - malformed", dataType: Binary, - value: "bad binary", - expectedErr: "expected []byte got string for value", + value: true, + expectedErr: "expected []byte or string got bool for value", }, { name: "varbinary",