Modified:
branches/5.2/CHANGES
branches/5.2/MySql.Data/Provider/Properties/Resources.Designer.cs
branches/5.2/MySql.Data/Provider/Properties/Resources.resx
branches/5.2/MySql.Data/Provider/Source/datareader.cs
branches/5.2/MySql.Data/Tests/Source/DataTypeTests.cs
Log:
- fixed MySqlDataReader.GetGuid to be more robust in how it attempts to read guid values (bug #41452)
Modified: branches/5.2/CHANGES
===================================================================
--- branches/5.2/CHANGES 2009-03-05 16:33:12 UTC (rev 1525)
+++ branches/5.2/CHANGES 2009-03-05 17:49:55 UTC (rev 1526)
@@ -19,6 +19,7 @@
still attempt to close the file which would yield a null reference exception (bug #43332)
- fixed Sql null value exception when an attempt was made to reset the password and
require question and answer was false. (bug #41408)
+- fixed MySqlDataReader.GetGuid to be more robust in how it attempts to read guid values (bug #41452)
Version 5.2.5 - 11/14/2008
- fixed problem with package registration that kept the DDEX provider from working (bug #40726)
Modified: branches/5.2/MySql.Data/Provider/Properties/Resources.Designer.cs
===================================================================
--- branches/5.2/MySql.Data/Provider/Properties/Resources.Designer.cs 2009-03-05 16:33:12 UTC (rev 1525)
+++ branches/5.2/MySql.Data/Provider/Properties/Resources.Designer.cs 2009-03-05 17:49:55 UTC (rev 1526)
@@ -718,6 +718,15 @@
}
/// <summary>
+ /// Looks up a localized string similar to The requested column value could not be treated as or conveted to a Guid..
+ /// </summary>
+ public static string ValueNotSupportedForGuid {
+ get {
+ return ResourceManager.GetString("ValueNotSupportedForGuid", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Writing to the stream failed..
/// </summary>
public static string WriteToStreamFailed {
Modified: branches/5.2/MySql.Data/Provider/Properties/Resources.resx
===================================================================
--- branches/5.2/MySql.Data/Provider/Properties/Resources.resx 2009-03-05 16:33:12 UTC (rev 1525)
+++ branches/5.2/MySql.Data/Provider/Properties/Resources.resx 2009-03-05 17:49:55 UTC (rev 1526)
@@ -342,4 +342,7 @@
<data name="RoutineNotFound" xml:space="preserve">
<value>Routine '{0}' cannot be found. Either check the spelling or make sure you have sufficient rights to execute the routine.</value>
</data>
+ <data name="ValueNotSupportedForGuid" xml:space="preserve">
+ <value>The requested column value could not be treated as or conveted to a Guid.</value>
+ </data>
</root>
\ No newline at end of file
Modified: branches/5.2/MySql.Data/Provider/Source/datareader.cs
===================================================================
--- branches/5.2/MySql.Data/Provider/Source/datareader.cs 2009-03-05 16:33:12 UTC (rev 1525)
+++ branches/5.2/MySql.Data/Provider/Source/datareader.cs 2009-03-05 17:49:55 UTC (rev 1526)
@@ -490,7 +490,18 @@
/// <include file='docs/MySqlDataReader.xml' path='docs/GetGuid/*'/>
public override Guid GetGuid(int i)
{
- return new Guid(GetString(i));
+ object v = GetValue(i);
+ if (v is Guid)
+ return (Guid)v;
+ if (v is string)
+ return new Guid(v as string);
+ if (v is byte[])
+ {
+ byte[] bytes = (byte[])v;
+ if (bytes.Length == 16)
+ return new Guid(bytes);
+ }
+ throw new MySqlException(Resources.ValueNotSupportedForGuid);
}
/// <include file='docs/MySqlDataReader.xml' path='docs/GetInt16S/*'/>
Modified: branches/5.2/MySql.Data/Tests/Source/DataTypeTests.cs
===================================================================
--- branches/5.2/MySql.Data/Tests/Source/DataTypeTests.cs 2009-03-05 16:33:12 UTC (rev 1525)
+++ branches/5.2/MySql.Data/Tests/Source/DataTypeTests.cs 2009-03-05 17:49:55 UTC (rev 1526)
@@ -849,7 +849,7 @@
if (version < new Version(5, 0)) return;
execSQL("DROP TABLE IF EXISTS Test");
- execSQL("CREATE TABLE Test (id INT, g BINARY(16), c VARBINARY(16), c1 BINARY(17))");
+ execSQL("CREATE TABLE Test (id INT, g BINARY(16), c VARBINARY(16), c1 BINARY(255))");
Guid g = Guid.NewGuid();
byte[] bytes = g.ToByteArray();
@@ -868,6 +868,21 @@
Assert.IsTrue(dt.Rows[0][3] is byte[]);
Assert.AreEqual(g, dt.Rows[0][1]);
+
+ string s = BitConverter.ToString(bytes);
+
+ s = s.Replace("-", "");
+ string sql = String.Format("TRUNCATE TABLE Test;INSERT INTO Test VALUES(1,0x{0},NULL,NULL)", s);
+ execSQL(sql);
+
+ cmd.CommandText = "SELECT * FROM Test";
+ cmd.Parameters.Clear();
+ using (MySqlDataReader reader = cmd.ExecuteReader())
+ {
+ reader.Read();
+ Guid g1 = reader.GetGuid(1);
+ Assert.AreEqual(g, g1);
+ }
}
/// <summary>
| Thread |
|---|
| • Connector/NET commit: r1526 - in branches/5.2: . MySql.Data/Provider/Properties MySql.Data/Provider/Source MySql.Data/Tests/Source | rburnett | 5 Mar |