From 256db1a5500c1d71591e0cc147a1f9fe54865d0f Mon Sep 17 00:00:00 2001 From: Miguel Molina Date: Tue, 22 Oct 2019 15:01:08 +0200 Subject: [PATCH] sql: information schema column types should be lowercase Fixes #849 Signed-off-by: Miguel Molina --- engine_test.go | 17 ++++++++-------- sql/information_schema.go | 43 ++++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/engine_test.go b/engine_test.go index 5070589ee..0c3f4807f 100644 --- a/engine_test.go +++ b/engine_test.go @@ -18,7 +18,6 @@ import ( "github.com/src-d/go-mysql-server/sql/plan" "github.com/src-d/go-mysql-server/test" - "github.com/stretchr/testify/require" ) @@ -867,8 +866,8 @@ var queries = []struct { WHERE TABLE_SCHEMA='mydb' AND TABLE_NAME='mytable' `, []sql.Row{ - {"s", "TEXT"}, - {"i", "BIGINT"}, + {"s", "text"}, + {"i", "bigint"}, }, }, { @@ -2250,8 +2249,8 @@ func TestUpdate(t *testing.T) { var updates = []struct { updateQuery string expectedUpdate []sql.Row - selectQuery string - expectedSelect []sql.Row + selectQuery string + expectedSelect []sql.Row }{ { "UPDATE mytable SET s = 'updated';", @@ -2275,7 +2274,7 @@ func TestUpdate(t *testing.T) { "UPDATE mytable SET s = 'updated' WHERE i <> 9999;", []sql.Row{{int64(3), int64(3)}}, "SELECT * FROM mytable;", - []sql.Row{{int64(1), "updated"},{int64(2), "updated"},{int64(3), "updated"}}, + []sql.Row{{int64(1), "updated"}, {int64(2), "updated"}, {int64(3), "updated"}}, }, { "UPDATE floattable SET f32 = f32 + f32, f64 = f32 * f64 WHERE i = 2;", @@ -2477,7 +2476,7 @@ func TestCreateTable(t *testing.T) { testQuery(t, e, "CREATE TABLE t2 (a INTEGER NOT NULL PRIMARY KEY, "+ - "b VARCHAR(10) NOT NULL)", + "b VARCHAR(10) NOT NULL)", []sql.Row(nil), ) @@ -2496,8 +2495,8 @@ func TestCreateTable(t *testing.T) { testQuery(t, e, "CREATE TABLE t3(a INTEGER NOT NULL,"+ - "b TEXT NOT NULL,"+ - "c bool, primary key (a,b))", + "b TEXT NOT NULL,"+ + "c bool, primary key (a,b))", []sql.Row(nil), ) diff --git a/sql/information_schema.go b/sql/information_schema.go index d88804751..48147c7d5 100644 --- a/sql/information_schema.go +++ b/sql/information_schema.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "io" + "strings" ) const ( @@ -214,27 +215,27 @@ func columnsRowIter(cat *Catalog) RowIter { collName = "utf8_bin" } rows = append(rows, Row{ - "def", // table_catalog - db.Name(), // table_schema - t.Name(), // table_name - c.Name, // column_name - uint64(i), // ordinal_position - c.Default, // column_default - nullable, // is_nullable - MySQLTypeName(c.Type), // data_type - nil, // character_maximum_length - nil, // character_octet_length - nil, // numeric_precision - nil, // numeric_scale - nil, // datetime_precision - charName, // character_set_name - collName, // collation_name - MySQLTypeName(c.Type), // column_type - "", // column_key - "", // extra - "select", // privileges - "", // column_comment - "", // generation_expression + "def", // table_catalog + db.Name(), // table_schema + t.Name(), // table_name + c.Name, // column_name + uint64(i), // ordinal_position + c.Default, // column_default + nullable, // is_nullable + strings.ToLower(MySQLTypeName(c.Type)), // data_type + nil, // character_maximum_length + nil, // character_octet_length + nil, // numeric_precision + nil, // numeric_scale + nil, // datetime_precision + charName, // character_set_name + collName, // collation_name + strings.ToLower(MySQLTypeName(c.Type)), // column_type + "", // column_key + "", // extra + "select", // privileges + "", // column_comment + "", // generation_expression }) } }