Skip to content

Commit

Permalink
adding charset/collation tests
Browse files Browse the repository at this point in the history
Signed-off-by: Shlomi Noach <[email protected]>
  • Loading branch information
shlomi-noach committed May 8, 2024
1 parent 8f087d9 commit fc29830
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
12 changes: 12 additions & 0 deletions go/vt/schemadiff/schema_diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,18 @@ func TestSchemaDiff(t *testing.T) {
entityOrder: []string{"t1", "t2", "v2"},
instantCapability: InstantDDLCapabilityPossible,
},
{
name: "two identical tables, one with explicit charset, one without",
fromQueries: []string{
"create table foobar (id int primary key, foo varchar(64) character set utf8mb3 collate utf8mb3_bin)",
},
toQueries: []string{
"create table foobar (id int primary key, foo varchar(64) collate utf8mb3_bin)",
},
entityOrder: []string{},
instantCapability: InstantDDLCapabilityIrrelevant,
},

{
name: "instant DDL possible on 8.0.32",
toQueries: []string{
Expand Down
10 changes: 10 additions & 0 deletions go/vt/schemadiff/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1878,6 +1878,11 @@ func TestCreateTableDiff(t *testing.T) {
diff: "alter table t collate utf8mb4_0900_bin",
cdiff: "ALTER TABLE `t` COLLATE utf8mb4_0900_bin",
},
{
name: "ignore identical implicit charset",
from: "create table t (id int primary key, v varchar(64) character set utf8mb3 collate utf8mb3_bin)",
to: "create table t (id int primary key, v varchar(64) collate utf8mb3_bin)",
},
{
name: "normalized unsigned attribute",
from: "create table t1 (id int primary key)",
Expand Down Expand Up @@ -2889,6 +2894,11 @@ func TestNormalize(t *testing.T) {
from: "create table t (id int signed primary key, v varchar(255) charset utf8mb3 collate utf8_unicode_ci) charset utf8mb3 collate utf8_unicode_ci",
to: "CREATE TABLE `t` (\n\t`id` int,\n\t`v` varchar(255),\n\tPRIMARY KEY (`id`)\n) CHARSET utf8mb3,\n COLLATE utf8mb3_unicode_ci",
},
{
name: "remove column charset if collation is explicit and implies specified charset",
from: "create table t (id int primary key, v varchar(255) charset utf8mb4 collate utf8mb4_german2_ci)",
to: "CREATE TABLE `t` (\n\t`id` int,\n\t`v` varchar(255) COLLATE utf8mb4_german2_ci,\n\tPRIMARY KEY (`id`)\n)",
},
{
name: "correct case table options for engine",
from: "create table t (id int signed primary key) engine innodb",
Expand Down

0 comments on commit fc29830

Please sign in to comment.