MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:rburnett Date:January 30 2007 9:57pm
Subject:Connector/NET commit: r571 - 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/MySqlTime.cs
Log:
Bug #25912 selecting negative time values gets wrong results 

The problem here is that we are using a TimeSpan struct to hold time values.  The ctor for TimeSpan applies each value to the total time value.  So passing in -7 hours along with a positive 24 minutes results in -7 hours + 24 minutes which is -6 hours and 36 minutes.  The fix was to negate each value if the hours value is negative.

Modified: branches/1.0/CHANGES
===================================================================
--- branches/1.0/CHANGES	2007-01-30 21:48:56 UTC (rev 570)
+++ branches/1.0/CHANGES	2007-01-30 21:57:01 UTC (rev 571)
@@ -24,6 +24,7 @@
     Bug #25651 SELECT does not work properly when WHERE contains UTF-8 characters 
     Bug #25726 MySqlConnection throws NullReferenceException and ArgumentNullException 
     Bug #25609 MySqlDataAdapter.FillSchema 
+    Bug #25912 selecting negative time values gets wrong results 
 
     Other changes
     -------------

Modified: branches/1.0/TestSuite/DateTimeTests.cs
===================================================================
--- branches/1.0/TestSuite/DateTimeTests.cs	2007-01-30 21:48:56 UTC (rev 570)
+++ branches/1.0/TestSuite/DateTimeTests.cs	2007-01-30 21:57:01 UTC (rev 571)
@@ -478,6 +478,26 @@
 					c.Close();
 			}
 		}
+
+        /// <summary>
+        /// Bug #25912 selecting negative time values gets wrong results 
+        /// </summary>
+        [Test]
+        public void TestNegativeTime()
+        {
+            execSQL("DROP TABLE IF EXISTS test");
+            execSQL("CREATE TABLE test (t time)");
+            execSQL("INSERT INTO test SET T='-07:24:00'");
+
+            MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM test", conn);
+            DataTable dt = new DataTable();
+            da.Fill(dt);
+
+            TimeSpan ts = (TimeSpan)dt.Rows[0]["t"];
+            Assert.AreEqual(-7, ts.Hours);
+            Assert.AreEqual(-24, ts.Minutes);
+            Assert.AreEqual(0, ts.Seconds);
+        }
 	}
 
 }

Modified: branches/1.0/mysqlclient/Types/MySqlTime.cs
===================================================================
--- branches/1.0/mysqlclient/Types/MySqlTime.cs	2007-01-30 21:48:56 UTC (rev 570)
+++ branches/1.0/mysqlclient/Types/MySqlTime.cs	2007-01-30 21:57:01 UTC (rev 571)
@@ -89,6 +89,11 @@
 			int hours = Int32.Parse( parts[0] );
 			int mins = Int32.Parse( parts[1] );
 			int secs = Int32.Parse( parts[2] );
+            if (hours < 0)
+            {
+                mins *= -1;
+                secs *= -1;
+            }
 			int days = hours / 24;
 			hours = hours - (days * 24);
 			Value = new TimeSpan( days, hours, mins, secs, 0 );

Thread
Connector/NET commit: r571 - in branches/1.0: . TestSuite mysqlclient/Typesrburnett30 Jan