Skip to content

Commit 3ae13c2

Browse files
author
Gabriela Martinez
committed
Merge remote-tracking branch 'remotes/origin/6.8' into 6.9
2 parents 07b81dc + 945e9c8 commit 3ae13c2

File tree

5 files changed

+58
-3
lines changed

5 files changed

+58
-3
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
6.9.8
22
- Added support for Chinese character set gb18030. (Oracle bug # 21098546).
3+
- Added support for Json type. (WL # 8132).
34

45
6.9.7
56
- Changed default SSL mode to Preferred in connection string. Now the server connections will be using SSL if server allows it by default but it's possible to override this configuration.

Source/MySql.Data/Field.cs

Lines changed: 2 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
@@ -374,6 +374,7 @@ public static IMySqlValue GetIMySqlValue(MySqlDbType type)
374374
case MySqlDbType.TinyText:
375375
case MySqlDbType.MediumText:
376376
case MySqlDbType.LongText:
377+
case MySqlDbType.JSON:
377378
case (MySqlDbType)Field_Type.NULL:
378379
return new MySqlString(type, true);
379380
#if !CF

Source/MySql.Data/MysqlDefs.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2004, 2011, 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
@@ -201,6 +201,10 @@ public enum MySqlDbType
201201
/// </summary>
202202
Bit = 16,
203203
/// <summary>
204+
/// JSON
205+
/// </summary>
206+
JSON = 245,
207+
/// <summary>
204208
/// New Decimal
205209
/// </summary>
206210
NewDecimal = 246,

Tests/MySql.Data.Tests/DataTypeTests.cs

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2013, 2014 Oracle and/or its affiliates. All rights reserved.
1+
// Copyright © 2013, 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
@@ -1277,5 +1277,52 @@ public void Timediff()
12771277
var result = cmd.ExecuteScalar();
12781278
Assert.Equal(new TimeSpan(new TimeSpan(-2, -1, -1, -2).Ticks - 1234560), result);
12791279
}
1280+
1281+
[Fact]
1282+
public void CanReadJsonValue()
1283+
{
1284+
st.execSQL("DROP TABLE IF EXISTS test");
1285+
st.execSQL("CREATE TABLE test(Id int NOT NULL PRIMARY KEY, jsoncolumn JSON)");
1286+
1287+
MySqlCommand cmd = new MySqlCommand("INSERT INTO test VALUES (@id, '[1]')", st.conn);
1288+
cmd.Parameters.AddWithValue("@id", 1);
1289+
cmd.ExecuteNonQuery();
1290+
1291+
string command = @"INSERT INTO test VALUES (@id, '[""a"", {""b"": [true, false]}, [10, 20]]')";
1292+
cmd = new MySqlCommand(command, st.conn);
1293+
cmd.Parameters.AddWithValue("@id", 2);
1294+
cmd.ExecuteNonQuery();
1295+
1296+
cmd = new MySqlCommand("SELECT jsoncolumn from test where id = 2 ", st.conn);
1297+
1298+
using (MySqlDataReader reader = cmd.ExecuteReader())
1299+
{
1300+
Assert.True(reader.Read());
1301+
Assert.Equal("[\"a\", {\"b\": [true, false]}, [10, 20]]", reader.GetString(0));
1302+
}
1303+
}
1304+
1305+
[Fact]
1306+
public void CanUpdateJsonValue()
1307+
{
1308+
st.execSQL("DROP TABLE IF EXISTS test");
1309+
st.execSQL("CREATE TABLE test(Id int NOT NULL PRIMARY KEY, jsoncolumn JSON)");
1310+
1311+
MySqlCommand cmd = new MySqlCommand("INSERT INTO test VALUES (@id, '[1]')", st.conn);
1312+
cmd.Parameters.AddWithValue("@id", 1);
1313+
cmd.ExecuteNonQuery();
1314+
1315+
string command = @"UPDATE test set jsoncolumn = '[""a"", {""b"": [true, false]}, [10, 20]]' where id = 1";
1316+
cmd = new MySqlCommand(command, st.conn);
1317+
cmd.ExecuteNonQuery();
1318+
1319+
cmd = new MySqlCommand("SELECT jsoncolumn from test where id = 1 ", st.conn);
1320+
1321+
using (MySqlDataReader reader = cmd.ExecuteReader())
1322+
{
1323+
Assert.True(reader.Read());
1324+
Assert.Equal("[\"a\", {\"b\": [true, false]}, [10, 20]]", reader.GetString(0));
1325+
}
1326+
}
12801327
}
12811328
}

Tests/MySql.Data.Tests/MySqlConnectionTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,8 @@ public void PasswordExpiration()
11291129
[Fact]
11301130
public void OldPasswordNotSupported()
11311131
{
1132+
1133+
if (st.Version > new Version(5, 6)) return;
11321134
//get value of flag 'old_passwords'
11331135
MySqlConnectionStringBuilder csb = new MySqlConnectionStringBuilder(st.GetConnectionString(true));
11341136
MySqlConnection con = new MySqlConnection(csb.ToString());

0 commit comments

Comments
 (0)