Skip to content
This repository was archived by the owner on Apr 16, 2024. It is now read-only.

Commit e4e43a0

Browse files
author
Gabriela Martinez
committed
Merge remote-tracking branch 'remotes/origin/6.7' into 6.8
2 parents a0eaf88 + 82ca9bf commit e4e43a0

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
- Changed handshake process to use bytes instead of encoded strings.
33
- Added support for Chinese character set gb18030. (Oracle bug # 21098546).
44
- Added support for Json type. (WL # 8132).
5+
- Added changes for metadata information in generated columns with 5.7 (WL #411)
56

67

78
6.8.6

Source/MySql.Data/SchemaProvider.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2004, 2013, Oracle and/or its affiliates. All rights reserved.
1+
// Copyright © 2004, 2015, Oracle and/or its affiliates. All rights reserved.
22
//
33
// MySQL Connector/NET is licensed under the terms of the GPLv2
44
// <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -175,6 +175,7 @@ public virtual MySqlSchemaCollection GetColumns(string[] restrictions)
175175
c.AddColumn("EXTRA", typeof(string));
176176
c.AddColumn("PRIVILEGES", typeof(string));
177177
c.AddColumn("COLUMN_COMMENT", typeof(string));
178+
c.AddColumn("GENERATION_EXPRESSION", typeof(string));
178179

179180
// we don't allow restricting on table type here
180181
string columnName = null;
@@ -228,6 +229,7 @@ private void LoadTableColumns(MySqlSchemaCollection schemaCollection, string sch
228229
row["EXTRA"] = reader.GetString(6);
229230
row["PRIVILEGES"] = reader.GetString(7);
230231
row["COLUMN_COMMENT"] = reader.GetString(8);
232+
row["GENERATION_EXPRESION"] = reader.GetString(6).Contains("VIRTUAL") ? reader.GetString(9) : string.Empty;
231233
ParseColumnRow(row);
232234
}
233235
}

Tests/MySql.Data.Tests/GetSchemaTests.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,34 @@ col3 varchar(50) character set utf8, col4 tinyint unsigned,
257257
Assert.Equal("BOO", dt.Rows[4]["COLUMN_DEFAULT"].ToString().ToUpper());
258258
}
259259

260+
261+
///<summary>
262+
///Testing out schema information about generated columns
263+
/// only in version 5.7.6 or later
264+
///</summary>
265+
[Fact]
266+
public void CanGetSchemaInformationGeneratedColumns()
267+
{
268+
if (st.Version < new Version(5, 7, 6)) return;
269+
270+
st.execSQL("DROP TABLE IF EXISTS test");
271+
st.execSQL("CREATE TABLE `Test` (`ID` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `Name` char(35) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL)");
272+
273+
var cmd = new MySqlCommand("ALTER TABLE test ADD COLUMN Name_ci char(35) CHARACTER SET utf8 AS (Name) STORED;", st.conn);
274+
cmd.ExecuteNonQuery();
275+
276+
DataTable dt = st.conn.GetSchema("Columns", new string[] { null, null, "test", null });
277+
Assert.Equal(3, dt.Rows.Count);
278+
Assert.Equal("Columns", dt.TableName);
279+
if (st.Version.Major >= 5 && st.Version.Minor >= 7 && st.Version.Build >= 6)
280+
{
281+
Assert.Equal("char", dt.Rows[2]["DATA_TYPE"]);
282+
Assert.Equal("Name", dt.Rows[2]["GENERATION_EXPRESSION"]);
283+
Assert.Equal("STORED GENERATED", dt.Rows[2]["EXTRA"]);
284+
}
285+
}
286+
287+
260288
/// <summary>
261289
/// Bug #46270 connection.GetSchema("Columns") fails on MySQL 4.1
262290
/// </summary>

Tests/MySql.Data.Tests/SetUp.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ protected void LoadBaseConfiguration()
173173
if (string.IsNullOrEmpty(rootUser))
174174
rootUser = "root";
175175
if (string.IsNullOrEmpty(rootPassword))
176-
rootPassword = string.Empty;
176+
rootPassword = "mypass";
177177
if (string.IsNullOrEmpty(host))
178178
host = "localhost";
179179
if (string.IsNullOrEmpty(portString))

0 commit comments

Comments
 (0)