Skip to content

Commit

Permalink
ColumnDiff takes Environment. When a column specifies a collation wit…
Browse files Browse the repository at this point in the history
…hout a charset, we use Envronment to autopopulate the charset, or return an error what that is not possible

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
  • Loading branch information
shlomi-noach committed Jan 11, 2024
1 parent 5784dc3 commit 26acffc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions go/vt/schemadiff/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,16 @@ func TestDiffTables(t *testing.T) {
TableCharsetCollateStrategy: TableCharsetCollateIgnoreAlways,
},
},
{
name: "error on unknown collation",
from: "create table t (a varchar(64) COLLATE latin1_nonexisting) default charset=utf8mb4",
to: "create table t (a varchar(64) CHARACTER SET latin1 COLLATE latin1_bin)",
hints: &DiffHints{
AlterTableAlgorithmStrategy: AlterTableAlgorithmStrategyCopy,
TableCharsetCollateStrategy: TableCharsetCollateIgnoreAlways,
},
isError: true,
},
{
name: "changing table level defaults with column specific settings",
from: "create table t (a varchar(64) CHARACTER SET latin1 COLLATE latin1_bin) default charset=latin1",
Expand Down
2 changes: 1 addition & 1 deletion go/vt/schemadiff/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -1575,7 +1575,7 @@ func (c *CreateTableEntity) diffColumns(alterTable *sqlparser.AlterTable,
t2ColEntity := NewColumnDefinitionEntity(t2Col)

// check diff between before/after columns:
modifyColumnDiff, err := t1ColEntity.ColumnDiff(t2ColEntity, t1cc, t2cc)
modifyColumnDiff, err := t1ColEntity.ColumnDiff(c.Env, t2ColEntity, t1cc, t2cc)
if err != nil {
return err
}
Expand Down

0 comments on commit 26acffc

Please sign in to comment.