Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schemadiff: adding charset/collation tests #15872

Merged
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
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
Loading