List:Commits« Previous MessageNext Message »
From:Reggie Burnett Date:January 13 2012 5:58pm
Subject:bzr commit into connector-net-6.3 branch (reggie.burnett:1110) Bug#63812
Bug#13591554
View as plain text  
#At file:///C:/work/connector-net/6.3/ based on revid:fer.gonzalez@stripped

 1110 Reggie Burnett	2012-01-13
      - Return datetime values for timestamp fields as DateTimeKind.Local (MySQL bug #63812, Oracle bug #13591554)

    modified:
      CHANGES
      Source/MySql.Data/Types/MySqlDateTime.cs
      Tests/MySql.Data.Tests/DateTimeTests.cs
=== modified file 'CHANGES'
=== modified file 'CHANGES'
--- a/CHANGES	2012-01-09 21:17:00 +0000
+++ b/CHANGES	2012-01-13 17:58:23 +0000
@@ -1,5 +1,5 @@
-
 - Made MySqlDateTime serializable (MySQL bug #40555, Oracle bug #11750161).
+- Return datetime values for timestamp fields as DateTimeKind.Local (MySQL bug #63812, Oracle bug #13591554)
 
 Version 6.3.8
 - Modified ProviderManifest.xml to map TIMESTAMP db fields to the DateTime .NET type (MySQL bug #55351, Oracle bug #12652602).

=== modified file 'Source/MySql.Data/Types/MySqlDateTime.cs'
--- a/Source/MySql.Data/Types/MySqlDateTime.cs	2012-01-09 21:17:00 +0000
+++ b/Source/MySql.Data/Types/MySqlDateTime.cs	2012-01-13 17:58:23 +0000
@@ -382,8 +382,10 @@
     {
       if (!IsValidDateTime)
         throw new MySqlConversionException("Unable to convert MySQL date/time value to System.DateTime");
-
-      return new DateTime(year, month, day, hour, minute, second);
+      DateTimeKind kind = DateTimeKind.Unspecified;
+      if (type == MySqlDbType.Timestamp)
+        kind = DateTimeKind.Local;
+      return new DateTime(year, month, day, hour, minute, second, kind);
     }
 
     private static string FormatDateCustom(string format, int monthVal, int dayVal, int yearVal)

=== modified file 'Tests/MySql.Data.Tests/DateTimeTests.cs'
--- a/Tests/MySql.Data.Tests/DateTimeTests.cs	2011-12-16 22:12:42 +0000
+++ b/Tests/MySql.Data.Tests/DateTimeTests.cs	2012-01-13 17:58:23 +0000
@@ -427,6 +427,28 @@
         Assert.IsTrue(reader.Read());
       }
     }
+
+    /// <summary>
+    /// Bug #63812	MySqlDateTime.GetDateTime() does not specify Timezone for TIMESTAMP fields
+    /// </summary>
+    [Test]
+    public void TimestampValuesAreLocal()
+    {
+      DateTime dt = DateTime.Now;
+      MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES(1, ?dt, NULL, NULL, NULL)", conn);
+      cmd.Parameters.AddWithValue("@dt", dt);
+      cmd.ExecuteNonQuery();
+
+      cmd.CommandText = "SELECT dt,ts FROM Test";
+      using (MySqlDataReader reader = cmd.ExecuteReader())
+      {
+        reader.Read();
+        DateTime dt1 = reader.GetDateTime(0);
+        DateTime ts = reader.GetDateTime(1);
+        Assert.AreEqual(dt1.Kind, DateTimeKind.Unspecified);
+        Assert.AreEqual(ts.Kind, DateTimeKind.Local);
+      }
+    }
   }
 
 }


Attachment: [text/bzr-bundle] bzr/reggie.burnett@oracle.com-20120113175823-56ky832dx0m22cwh.bundle
Thread
bzr commit into connector-net-6.3 branch (reggie.burnett:1110) Bug#63812Bug#13591554Reggie Burnett16 Jan