Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit 53adb3b

Browse files
authored
Merge pull request #656 from mcuadros/show-create-table
plan: types in lowecase on SHOW CREATE TABLE
2 parents caa2047 + 6ddba19 commit 53adb3b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

sql/plan/show_create_table.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (i *showCreateTablesIter) Next() (sql.Row, error) {
7878
composedCreateTableStatement := produceCreateStatement(table)
7979

8080
return sql.NewRow(
81-
i.table, // "Table" string
81+
i.table, // "Table" string
8282
composedCreateTableStatement, // "Create Table" string
8383
), nil
8484
}
@@ -89,7 +89,8 @@ func produceCreateStatement(table sql.Table) string {
8989

9090
// Statement creation parts for each column
9191
for indx, col := range schema {
92-
createStmtPart := fmt.Sprintf(" `%s` %s", col.Name, col.Type.Type())
92+
createStmtPart := fmt.Sprintf(" `%s` %s", col.Name,
93+
strings.ToLower(col.Type.Type().String()))
9394

9495
if !col.Nullable {
9596
createStmtPart = fmt.Sprintf("%s NOT NULL", createStmtPart)

sql/plan/show_create_table_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ func TestShowCreateTable(t *testing.T) {
3737

3838
expected := sql.NewRow(
3939
table.Name(),
40-
"CREATE TABLE `test-table` (\n `baz` TEXT NOT NULL,\n"+
41-
" `zab` INT32 DEFAULT 0,\n"+
42-
" `bza` INT64 DEFAULT 0\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4",
40+
"CREATE TABLE `test-table` (\n `baz` text NOT NULL,\n"+
41+
" `zab` int32 DEFAULT 0,\n"+
42+
" `bza` int64 DEFAULT 0\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4",
4343
)
4444

4545
require.Equal(expected, row)

0 commit comments

Comments
 (0)