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

ALTER TABLE does not change column collations #84

Open
GaoYusong opened this issue Sep 13, 2024 · 0 comments
Open

ALTER TABLE does not change column collations #84

GaoYusong opened this issue Sep 13, 2024 · 0 comments

Comments

@GaoYusong
Copy link
Contributor

{
		Name: "ALTER TABLE does not change column collations",
		SetUpScript: []string{
			"CREATE TABLE test1 (v1 VARCHAR(200), v2 ENUM('a'), v3 SET('a'));",
			"CREATE TABLE test2 (v1 VARCHAR(200), v2 ENUM('a'), v3 SET('a')) COLLATE=utf8mb4_general_ci;",
			"CREATE TABLE test3 (v1 VARCHAR(200) COLLATE utf8mb4_general_ci, v2 ENUM('a'), v3 SET('a') CHARACTER SET utf8mb3) COLLATE=utf8mb4_general_ci",
			"CREATE TABLE test4 (v1 VARCHAR(200) COLLATE utf8mb4_0900_ai_ci, v2 ENUM('a') COLLATE utf8mb4_general_ci, v3 SET('a') COLLATE utf8mb4_unicode_ci) COLLATE=utf8mb4_bin;",
		},
		Assertions: []ScriptTestAssertion{
			{
				Query: "SHOW CREATE TABLE test1",
				Expected: []sql.Row{{"test1",
					"CREATE TABLE `test1` (\n" +
						"  `v1` varchar(200),\n" +
						"  `v2` enum('a'),\n" +
						"  `v3` set('a')\n" +
						") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
			},
			{
				Query: "SHOW CREATE TABLE test2",
				Expected: []sql.Row{{"test2",
					"CREATE TABLE `test2` (\n" +
						"  `v1` varchar(200),\n" +
						"  `v2` enum('a'),\n" +
						"  `v3` set('a')\n" +
						") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"}},
			},
			{
				Query: "SHOW CREATE TABLE test3",
				Expected: []sql.Row{{"test3",
					"CREATE TABLE `test3` (\n" +
						"  `v1` varchar(200),\n" +
						"  `v2` enum('a'),\n" +
						"  `v3` set('a') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci\n" +
						") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"}},
			},
			{
				Query: "SHOW CREATE TABLE test4",
				Expected: []sql.Row{{"test4",
					"CREATE TABLE `test4` (\n" +
						"  `v1` varchar(200) COLLATE utf8mb4_0900_ai_ci,\n" +
						"  `v2` enum('a') COLLATE utf8mb4_general_ci,\n" +
						"  `v3` set('a') COLLATE utf8mb4_unicode_ci\n" +
						") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"}},
			},
			{
				Query:    "ALTER TABLE test1 COLLATE utf8mb4_general_ci;",
				Expected: []sql.Row{{types.NewOkResult(0)}},
			},
			{
				Query:    "ALTER TABLE test2 COLLATE utf8mb4_0900_bin;",
				Expected: []sql.Row{{types.NewOkResult(0)}},
			},
			{
				Query:    "ALTER TABLE test3 COLLATE utf8mb4_0900_bin;",
				Expected: []sql.Row{{types.NewOkResult(0)}},
			},
			{
				Query:    "ALTER TABLE test4 COLLATE utf8mb4_unicode_ci;",
				Expected: []sql.Row{{types.NewOkResult(0)}},
			},
			{
				Query: "SHOW CREATE TABLE test1",
				Expected: []sql.Row{{"test1",
					"CREATE TABLE `test1` (\n" +
						"  `v1` varchar(200) COLLATE utf8mb4_0900_bin,\n" +
						"  `v2` enum('a') COLLATE utf8mb4_0900_bin,\n" +
						"  `v3` set('a') COLLATE utf8mb4_0900_bin\n" +
						") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"}},
			},
			{
				Query: "SHOW CREATE TABLE test2",
				Expected: []sql.Row{{"test2",
					"CREATE TABLE `test2` (\n" +
						"  `v1` varchar(200) COLLATE utf8mb4_general_ci,\n" +
						"  `v2` enum('a') COLLATE utf8mb4_general_ci,\n" +
						"  `v3` set('a') COLLATE utf8mb4_general_ci\n" +
						") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
			},
			{
				Query: "SHOW CREATE TABLE test3",
				Expected: []sql.Row{{"test3",
					"CREATE TABLE `test3` (\n" +
						"  `v1` varchar(200) COLLATE utf8mb4_general_ci,\n" +
						"  `v2` enum('a') COLLATE utf8mb4_general_ci,\n" +
						"  `v3` set('a') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci\n" +
						") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
			},
			{
				Query: "SHOW CREATE TABLE test4",
				Expected: []sql.Row{{"test4",
					"CREATE TABLE `test4` (\n" +
						"  `v1` varchar(200) COLLATE utf8mb4_0900_ai_ci,\n" +
						"  `v2` enum('a') COLLATE utf8mb4_general_ci,\n" +
						"  `v3` set('a')\n" +
						") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}},
			},
		},
	},
--- FAIL: TestAlterTable/ALTER_TABLE_does_not_change_column_collations (0.11s)
        --- FAIL: TestAlterTable/ALTER_TABLE_does_not_change_column_collations/SHOW_CREATE_TABLE_test2 (0.01s)
            /Users/shannon/code/myduckserver/evaluation.go:726: 
                	Error Trace:	/Users/shannon/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/enginetest/evaluation.go:726
                	            				/Users/shannon/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/enginetest/evaluation.go:357
                	Error:      	Not equal: 
                	            	expected: []sql.Row{sql.Row{"test2", "CREATE TABLE `test2` (\n  `v1` varchar(200),\n  `v2` enum('a'),\n  `v3` set('a')\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"}}
                	            	actual  : []sql.Row{sql.Row{"test2", "CREATE TABLE `test2` (\n  `v1` varchar(200) COLLATE utf8mb4_general_ci,\n  `v2` enum('a') COLLATE utf8mb4_general_ci,\n  `v3` set('a') COLLATE utf8mb4_general_ci\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}}
                	            	
                	            	Diff:
                	            	--- Expected
                	            	+++ Actual
                	            	@@ -3,3 +3,3 @@
                	            	   (string) (len=5) "test2",
                	            	-  (string) (len=144) "CREATE TABLE `test2` (\n  `v1` varchar(200),\n  `v2` enum('a'),\n  `v3` set('a')\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
                	            	+  (string) (len=223) "CREATE TABLE `test2` (\n  `v1` varchar(200) COLLATE utf8mb4_general_ci,\n  `v2` enum('a') COLLATE utf8mb4_general_ci,\n  `v3` set('a') COLLATE utf8mb4_general_ci\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"
                	            	  }
                	Test:       	TestAlterTable/ALTER_TABLE_does_not_change_column_collations/
@GaoYusong GaoYusong changed the title "ALTER TABLE does not change column collations ALTER TABLE does not change column collations Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant