Skip to content

Commit

Permalink
internal/integration: add testscript for column charset/collate changes
Browse files Browse the repository at this point in the history
  • Loading branch information
a8m committed Jun 16, 2022
1 parent dacb0ec commit 6cfdae0
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions internal/integration/testdata/mysql/column-charset.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
apply 1.hcl
cmpshow users 1.sql

# Dropping the default COLLATE from the HCL does not have any effect.
apply 2.hcl
cmpshow users 1.sql

# Changing the default COLLATE to hebrew_bin.
apply 3.hcl
cmpshow users 3.sql

# Dropping custom COLLATE reverts to the default.
apply 4.hcl
cmpshow users 1.sql

# Dropping CHARSET and COLLATE.
apply 5.hcl
cmpshow users 5.sql

-- 1.hcl --
schema "$db" {
charset = "$charset"
Expand All @@ -27,3 +43,77 @@ CREATE TABLE `users` (
CREATE TABLE `users` (
`name` varchar(255) CHARACTER SET hebrew COLLATE hebrew_general_ci NOT NULL
)

-- 2.hcl --
schema "$db" {
charset = "$charset"
collate = "$collate"
}

table "users" {
schema = schema.$db
column "name" {
type = varchar(255)
charset = "hebrew"
}
charset = "$charset"
collate = "$collate"
}

-- 3.hcl --
schema "$db" {
charset = "$charset"
collate = "$collate"
}

table "users" {
schema = schema.$db
column "name" {
type = varchar(255)
charset = "hebrew"
collate = "hebrew_bin"
}
charset = "$charset"
collate = "$collate"
}

-- 3.sql --
CREATE TABLE `users` (
`name` varchar(255) CHARACTER SET hebrew COLLATE hebrew_bin NOT NULL
)

-- 4.hcl --
schema "$db" {
charset = "$charset"
collate = "$collate"
}

table "users" {
schema = schema.$db
column "name" {
type = varchar(255)
charset = "hebrew"
}
charset = "$charset"
collate = "$collate"
}

-- 5.hcl --
schema "$db" {
charset = "$charset"
collate = "$collate"
}

table "users" {
schema = schema.$db
column "name" {
type = varchar(255)
}
charset = "$charset"
collate = "$collate"
}

-- 5.sql --
CREATE TABLE `users` (
`name` varchar(255) NOT NULL
)

0 comments on commit 6cfdae0

Please sign in to comment.