Skip to content

Commit 74ea3b9

Browse files
authored
Add broader support for MySQL DDL statements (#675)
* endtoend: Update drop column test * dolphin: Add test for ALTER TABLE DROP COLUMN * dolphin: Implement ALTER TABLE MODIFY COLUMN * dolphin: Implement DROP COLUMN IF NOT EXISTS * dolphin: Implement ALTER TABLE DROP CONSTRAINT * endtoend: Combine similar DROP NOT NULL tests * dolphin: Implement ALTER TABLE RENAME TO * dolphin: Remove duplicate RENAME TABLE test * dolphin: Implement ALTER TABLE RENAME COLUMN * dolphin: Add test for changing column data type * dolphin: Add test for setting column as not null * dolphin: Fix failing tests * dolphin: Skip ALTER TABLE SET SCHEMA * dolphin: Support table and column comments
1 parent 3f40b50 commit 74ea3b9

File tree

69 files changed

+591
-36
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+591
-36
lines changed

internal/codegen/golang/mysql_type.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ func mysqlType(r *compiler.Result, col *compiler.Column, settings config.Combine
6565
case "json":
6666
return "json.RawMessage"
6767

68+
case "any":
69+
return "interface{}"
70+
6871
default:
6972
log.Printf("unknown MySQL type: %s\n", columnType)
7073
return "interface{}"

internal/endtoend/testdata/ddl_alter_table_drop_not_null/postgresql/go/models.go renamed to internal/endtoend/testdata/ddl_alter_table_column_drop_not_null/mysql/go/models.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/* name: Placeholder :exec */
2+
SELECT 1;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CREATE TABLE foo (bar text NOT NULL, baz text NOT NULL);
2+
ALTER TABLE foo MODIFY COLUMN bar text;
3+
ALTER TABLE foo MODIFY baz text;

internal/endtoend/testdata/ddl_alter_table_drop_not_null/postgresql/sqlc.json renamed to internal/endtoend/testdata/ddl_alter_table_column_drop_not_null/mysql/sqlc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"packages": [
44
{
55
"path": "go",
6-
"engine": "postgresql",
6+
"engine": "mysql:beta",
77
"name": "querytest",
88
"schema": "schema.sql",
99
"queries": "query.sql"
1010
}
1111
]
12-
}
12+
}

internal/endtoend/testdata/ddl_alter_table_column_drop_not_null/postgresql/go/models.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
CREATE TABLE foo (bar text NOT NULL);
2-
ALTER TABLE foo ALTER COLUMN bar DROP NOT NULL;
1+
CREATE TABLE foo (bar text NOT NULL, baz text NOT NULL);
2+
ALTER TABLE foo ALTER COLUMN bar DROP NOT NULL;
3+
ALTER TABLE foo ALTER baz DROP NOT NULL;

0 commit comments

Comments
 (0)