List:Commits« Previous MessageNext Message »
From:rburnett Date:September 28 2006 5:57pm
Subject:Connector/NET commit: r369 - in branches/1.0: . TestSuite mysqlclient/Types
View as plain text  
Modified:
   branches/1.0/CHANGES
   branches/1.0/TestSuite/DateTimeTests.cs
   branches/1.0/mysqlclient/Types/MySqlDateTime.cs
Log:
Bug #15112 MySqlDateTime Constructor 

Added some public constructors for MySqlDateTime

Modified: branches/1.0/CHANGES
===================================================================
--- branches/1.0/CHANGES	2006-09-28 15:51:19 UTC (rev 368)
+++ branches/1.0/CHANGES	2006-09-28 15:57:14 UTC (rev 369)
@@ -34,6 +34,7 @@
 	Bug #18391 Better error handling for the .NET class "MySqlCommand" needed. 	
 	Bug #8131 Data Adapter doesn't close connection 
 	Bug #9619 Cannot update row using DbDataAdapter when row contains an invalid date 
+	Bug #15112 MySqlDateTime Constructor 	
 	
 x-xx-05 - Version 1.0.7
 

Modified: branches/1.0/TestSuite/DateTimeTests.cs
===================================================================
--- branches/1.0/TestSuite/DateTimeTests.cs	2006-09-28 15:51:19 UTC (rev 368)
+++ branches/1.0/TestSuite/DateTimeTests.cs	2006-09-28 15:57:14 UTC (rev 369)
@@ -151,6 +151,7 @@
 
         /// <summary>
         /// Bug #9619 Cannot update row using DbDataAdapter when row contains an invalid
date 
+        /// Bug #15112 MySqlDateTime Constructor 
         /// </summary>
         [Test]
         public void TestAllowZeroDateTime()
@@ -187,7 +188,21 @@
                 MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
                 da.Fill(dt);
                 dt.Rows[0]["id"] = 2;
+                DataRow row = dt.NewRow();
+                row["id"] = 3;
+                row["d"] = new MySqlDateTime("2003-9-24");
+                row["dt"] = new MySqlDateTime("0000/0/00 00:00:00");
+                dt.Rows.Add(row);
+
                 da.Update(dt);
+
+                dt.Clear();
+                da.Fill(dt);
+                Assert.AreEqual(2, dt.Rows.Count);
+                MySqlDateTime date = (MySqlDateTime)dt.Rows[1]["d"];
+                Assert.AreEqual(2003, date.Year);
+                Assert.AreEqual(9, date.Month);
+                Assert.AreEqual(24, date.Day);
             }
             catch (Exception ex)
             {

Modified: branches/1.0/mysqlclient/Types/MySqlDateTime.cs
===================================================================
--- branches/1.0/mysqlclient/Types/MySqlDateTime.cs	2006-09-28 15:51:19 UTC (rev 368)
+++ branches/1.0/mysqlclient/Types/MySqlDateTime.cs	2006-09-28 15:57:14 UTC (rev 369)
@@ -34,8 +34,36 @@
 		private static string	fullPattern;
 		private static string	shortPattern;
 
-		internal MySqlDateTime( int year, int month, int day, int hour, int minute, 
-			int second, MySqlDbType type ) : this(type)
+
+        public MySqlDateTime(int year, int month, int day, int hour, int minute, int
second)
+            : this(year, month, day, hour, minute, second, MySqlDbType.Datetime)
+        {
+        }
+
+        public MySqlDateTime(DateTime dt)
+            : this(dt, MySqlDbType.Datetime)
+        {
+        }
+
+        public MySqlDateTime(MySqlDateTime mdt)
+        {
+            year = mdt.Year;
+            month = mdt.Month;
+            day = mdt.Day;
+            hour = mdt.Hour;
+            minute = mdt.Minute;
+            second = mdt.Second;
+            mySqlDbType = MySqlDbType.Datetime;
+            isNull = false;
+        }
+
+        public MySqlDateTime(string s)
+            : this(MySqlDateTime.Parse(s))
+        {
+        }
+
+		internal MySqlDateTime(int year, int month, int day, int hour, int minute, 
+			int second, MySqlDbType type) : this(type)
 		{
 			this.year = year;
 			this.month = month;
@@ -274,12 +302,18 @@
 				                     second, mySqlDbType );
 		}
 
-		internal MySqlDateTime ParseMySql( string s, bool is41 ) 
+        internal static MySqlDateTime Parse(string s)
+        {
+            MySqlDateTime dt = new MySqlDateTime(MySqlDbType.Datetime);
+            return dt.ParseMySql(s, true);
+        }
+
+		internal MySqlDateTime ParseMySql(string s, bool is41) 
 		{
 			if (mySqlDbType == MySqlDbType.Timestamp && ! is41)
 				return Parse40Timestamp(s);
 
-			string[] parts = s.Split( '-', ' ', ':' );
+			string[] parts = s.Split( '-', ' ', ':', '/' );
 			
 			int year = int.Parse( parts[0] );
 			int month = int.Parse( parts[1] );

Thread
Connector/NET commit: r369 - in branches/1.0: . TestSuite mysqlclient/Typesrburnett28 Sep