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

Commit 0ddfce4

Browse files
committed
sql: Add length to VARCHAR MySQLTypeName string
Signed-off-by: Carlos Martín <carlos.martin.sanchez@gmail.com>
1 parent 89e8320 commit 0ddfce4

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

sql/plan/show_create_table_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func TestShowCreateTable(t *testing.T) {
1919
&sql.Column{Name: "baz", Type: sql.Text, Default: "", Nullable: false},
2020
&sql.Column{Name: "zab", Type: sql.Int32, Default: int32(0), Nullable: true},
2121
&sql.Column{Name: "bza", Type: sql.Uint64, Default: uint64(0), Nullable: true},
22+
&sql.Column{Name: "foo", Type: sql.VarChar(123), Default: "", Nullable: true},
2223
})
2324

2425
db.AddTable(table.Name(), table)
@@ -39,7 +40,9 @@ func TestShowCreateTable(t *testing.T) {
3940
table.Name(),
4041
"CREATE TABLE `test-table` (\n `baz` text NOT NULL,\n"+
4142
" `zab` integer DEFAULT 0,\n"+
42-
" `bza` bigint unsigned DEFAULT 0\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4",
43+
" `bza` bigint unsigned DEFAULT 0,\n"+
44+
" `foo` varchar(123)\n"+
45+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4",
4346
)
4447

4548
require.Equal(expected, row)

sql/type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ func MySQLTypeName(t Type) string {
12581258
case sqltypes.Char:
12591259
return "CHAR"
12601260
case sqltypes.VarChar:
1261-
return "VARCHAR"
1261+
return fmt.Sprintf("VARCHAR(%v)", t.(varCharT).Capacity())
12621262
case sqltypes.Text:
12631263
return "TEXT"
12641264
case sqltypes.Bit:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy