diff --git a/internal/integration/mysql_test.go b/internal/integration/mysql_test.go index 9ea2d7f74f4..910150bdef0 100644 --- a/internal/integration/mysql_test.go +++ b/internal/integration/mysql_test.go @@ -186,7 +186,7 @@ func TestMySQL_AddColumns(t *testing.T) { &schema.Column{Name: "b", Type: &schema.ColumnType{Raw: "mediumblob", Type: &schema.BinaryType{T: "mediumblob"}}}, &schema.Column{Name: "c", Type: &schema.ColumnType{Raw: "blob", Type: &schema.BinaryType{T: "blob"}}}, &schema.Column{Name: "d", Type: &schema.ColumnType{Raw: "longblob", Type: &schema.BinaryType{T: "longblob"}}}, - &schema.Column{Name: "e", Type: &schema.ColumnType{Raw: "binary", Type: &schema.BinaryType{T: "binary"}}}, + &schema.Column{Name: "e", Type: &schema.ColumnType{Raw: "binary(255)", Type: &schema.BinaryType{T: "binary(255)"}}}, &schema.Column{Name: "f", Type: &schema.ColumnType{Raw: "varbinary(255)", Type: &schema.BinaryType{T: "varbinary(255)"}}, Default: &schema.Literal{V: "foo"}}, &schema.Column{Name: "g", Type: &schema.ColumnType{Type: &schema.StringType{T: "varchar", Size: 255}}}, &schema.Column{Name: "h", Type: &schema.ColumnType{Raw: "varchar(255)", Type: &schema.StringType{T: "varchar(255)"}}}, diff --git a/internal/integration/tidb_test.go b/internal/integration/tidb_test.go index 9d1535c2e53..da10418f61b 100644 --- a/internal/integration/tidb_test.go +++ b/internal/integration/tidb_test.go @@ -169,7 +169,7 @@ func TestTiDB_AddColumns(t *testing.T) { &schema.Column{Name: "b", Type: &schema.ColumnType{Raw: "mediumblob", Type: &schema.BinaryType{T: "mediumblob"}}}, &schema.Column{Name: "c", Type: &schema.ColumnType{Raw: "blob", Type: &schema.BinaryType{T: "blob"}}}, &schema.Column{Name: "d", Type: &schema.ColumnType{Raw: "longblob", Type: &schema.BinaryType{T: "longblob"}}}, - &schema.Column{Name: "e", Type: &schema.ColumnType{Raw: "binary", Type: &schema.BinaryType{T: "binary"}}}, + &schema.Column{Name: "e", Type: &schema.ColumnType{Raw: "binary(255)", Type: &schema.BinaryType{T: "binary(255)"}}}, &schema.Column{Name: "f", Type: &schema.ColumnType{Raw: "varbinary(255)", Type: &schema.BinaryType{T: "varbinary(255)"}}, Default: &schema.Literal{V: "foo"}}, &schema.Column{Name: "g", Type: &schema.ColumnType{Type: &schema.StringType{T: "varchar", Size: 255}}}, &schema.Column{Name: "h", Type: &schema.ColumnType{Raw: "varchar(255)", Type: &schema.StringType{T: "varchar(255)"}}}, diff --git a/sql/mysql/convert.go b/sql/mysql/convert.go index 4e8359eba8f..01a155fe0c8 100644 --- a/sql/mysql/convert.go +++ b/sql/mysql/convert.go @@ -28,10 +28,8 @@ func FormatType(t schema.Type) (string, error) { } case *schema.BinaryType: f = strings.ToLower(t.T) - if f == TypeVarBinary { - // Zero is also a valid length. - f = fmt.Sprintf("%s(%d)", f, t.Size) - } + // Zero is also a valid length. + f = fmt.Sprintf("%s(%d)", f, t.Size) case *schema.DecimalType: if f = strings.ToLower(t.T); f != TypeDecimal && f != TypeNumeric { return "", fmt.Errorf("mysql: unexpected decimal type: %q", t.T)