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

Commit fb6f70e

Browse files
authored
Merge pull request #851 from erizocosmico/fix/info-schema-type-case
sql: information schema column types should be lowercase
2 parents 6f000e2 + 256db1a commit fb6f70e

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

engine_test.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/src-d/go-mysql-server/sql/plan"
1919
"github.com/src-d/go-mysql-server/test"
2020

21-
2221
"github.com/stretchr/testify/require"
2322
)
2423

@@ -867,8 +866,8 @@ var queries = []struct {
867866
WHERE TABLE_SCHEMA='mydb' AND TABLE_NAME='mytable'
868867
`,
869868
[]sql.Row{
870-
{"s", "TEXT"},
871-
{"i", "BIGINT"},
869+
{"s", "text"},
870+
{"i", "bigint"},
872871
},
873872
},
874873
{
@@ -2250,8 +2249,8 @@ func TestUpdate(t *testing.T) {
22502249
var updates = []struct {
22512250
updateQuery string
22522251
expectedUpdate []sql.Row
2253-
selectQuery string
2254-
expectedSelect []sql.Row
2252+
selectQuery string
2253+
expectedSelect []sql.Row
22552254
}{
22562255
{
22572256
"UPDATE mytable SET s = 'updated';",
@@ -2275,7 +2274,7 @@ func TestUpdate(t *testing.T) {
22752274
"UPDATE mytable SET s = 'updated' WHERE i <> 9999;",
22762275
[]sql.Row{{int64(3), int64(3)}},
22772276
"SELECT * FROM mytable;",
2278-
[]sql.Row{{int64(1), "updated"},{int64(2), "updated"},{int64(3), "updated"}},
2277+
[]sql.Row{{int64(1), "updated"}, {int64(2), "updated"}, {int64(3), "updated"}},
22792278
},
22802279
{
22812280
"UPDATE floattable SET f32 = f32 + f32, f64 = f32 * f64 WHERE i = 2;",
@@ -2477,7 +2476,7 @@ func TestCreateTable(t *testing.T) {
24772476

24782477
testQuery(t, e,
24792478
"CREATE TABLE t2 (a INTEGER NOT NULL PRIMARY KEY, "+
2480-
"b VARCHAR(10) NOT NULL)",
2479+
"b VARCHAR(10) NOT NULL)",
24812480
[]sql.Row(nil),
24822481
)
24832482

@@ -2496,8 +2495,8 @@ func TestCreateTable(t *testing.T) {
24962495

24972496
testQuery(t, e,
24982497
"CREATE TABLE t3(a INTEGER NOT NULL,"+
2499-
"b TEXT NOT NULL,"+
2500-
"c bool, primary key (a,b))",
2498+
"b TEXT NOT NULL,"+
2499+
"c bool, primary key (a,b))",
25012500
[]sql.Row(nil),
25022501
)
25032502

sql/information_schema.go

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"fmt"
66
"io"
7+
"strings"
78
)
89

910
const (
@@ -214,27 +215,27 @@ func columnsRowIter(cat *Catalog) RowIter {
214215
collName = "utf8_bin"
215216
}
216217
rows = append(rows, Row{
217-
"def", // table_catalog
218-
db.Name(), // table_schema
219-
t.Name(), // table_name
220-
c.Name, // column_name
221-
uint64(i), // ordinal_position
222-
c.Default, // column_default
223-
nullable, // is_nullable
224-
MySQLTypeName(c.Type), // data_type
225-
nil, // character_maximum_length
226-
nil, // character_octet_length
227-
nil, // numeric_precision
228-
nil, // numeric_scale
229-
nil, // datetime_precision
230-
charName, // character_set_name
231-
collName, // collation_name
232-
MySQLTypeName(c.Type), // column_type
233-
"", // column_key
234-
"", // extra
235-
"select", // privileges
236-
"", // column_comment
237-
"", // generation_expression
218+
"def", // table_catalog
219+
db.Name(), // table_schema
220+
t.Name(), // table_name
221+
c.Name, // column_name
222+
uint64(i), // ordinal_position
223+
c.Default, // column_default
224+
nullable, // is_nullable
225+
strings.ToLower(MySQLTypeName(c.Type)), // data_type
226+
nil, // character_maximum_length
227+
nil, // character_octet_length
228+
nil, // numeric_precision
229+
nil, // numeric_scale
230+
nil, // datetime_precision
231+
charName, // character_set_name
232+
collName, // collation_name
233+
strings.ToLower(MySQLTypeName(c.Type)), // column_type
234+
"", // column_key
235+
"", // extra
236+
"select", // privileges
237+
"", // column_comment
238+
"", // generation_expression
238239
})
239240
}
240241
}

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