Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sources/mysql/mysqldump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestProcessMySQLDump_Scalar(t *testing.T) {
ty string
expected ddl.Type
}{
{"varbinary(100)", ddl.Type{Name: ddl.Bytes, Len: ddl.MaxLength}},
{"varbinary(100)", ddl.Type{Name: ddl.Bytes, Len: int64(100)}},
{"bigint", ddl.Type{Name: ddl.Int64}},
{"bool", ddl.Type{Name: ddl.Bool}},
{"boolean", ddl.Type{Name: ddl.Bool}},
Expand Down
12 changes: 11 additions & 1 deletion sources/mysql/toddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,23 @@ func toSpannerTypeInternal(srcType schema.Type, spType string) (ddl.Type, []inte
default:
return ddl.Type{Name: ddl.JSON}, nil
}
case "binary", "varbinary":
case "binary":
switch spType {
case ddl.String:
return ddl.Type{Name: ddl.String, Len: ddl.MaxLength}, nil
default:
return ddl.Type{Name: ddl.Bytes, Len: ddl.MaxLength}, nil
}
case "varbinary":
switch spType {
case ddl.String:
return ddl.Type{Name: ddl.String, Len: ddl.MaxLength}, nil
default:
if len(srcType.Mods) > 0 {
return ddl.Type{Name: ddl.Bytes, Len: srcType.Mods[0]}, nil
}
return ddl.Type{Name: ddl.Bytes, Len: ddl.MaxLength}, nil
}
case "tinyblob", "mediumblob", "blob", "longblob":
switch spType {
case ddl.String:
Expand Down
7 changes: 7 additions & 0 deletions sources/mysql/toddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ func TestToSpannerTypeInternal(t *testing.T) {
if errCheck != nil {
t.Errorf("Error in binary to default conversion")
}
spType, errCheck := toSpannerTypeInternal(schema.Type{"varbinary", []int64{10}, []int64{}}, "BYTES")
if errCheck != nil {
t.Errorf("Error in binary to default conversion")
}
assert.Equal(t, "BYTES", spType.Name)
assert.Equal(t, int64(10), spType.Len)
assert.Equal(t, false, spType.IsArray)
_, errCheck = toSpannerTypeInternal(schema.Type{"blob", []int64{1, 2, 3}, []int64{1, 2, 3}}, "STRING")
if errCheck != nil {
t.Errorf("Error in blob to string conversion")
Expand Down
Loading