PAtch by Adam Wendt
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Mon, 31 Aug 2009 09:47:49 +0000 (09:47 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Mon, 31 Aug 2009 09:47:49 +0000 (09:47 -0000)
svn path=/trunk/mcs/; revision=140952

mcs/class/System.Data/Mono.Data.SqlExpressions/ChangeLog
mcs/class/System.Data/Mono.Data.SqlExpressions/Comparison.cs
mcs/class/System.Data/Test/Mono.Data.SqlExpressions/ChangeLog
mcs/class/System.Data/Test/Mono.Data.SqlExpressions/DateComparisonTest.cs
mcs/class/System.Data/Test/Mono.Data.SqlExpressions/dateComparisonTest.xml

index c3663627b58252c7424fe8c45df0b56303134b1d..9affeac0f6d62fb548f9eaf869c722afe956bb8d 100644 (file)
@@ -1,7 +1,7 @@
 2009-07-23  Adam Wendt  <adam@awendtconsulting.com>
 
-       * Comparison.cs (Compare): Parse string if other object is DateTime
-       regardless of which side the DateTime is on.
+       * Comparison.cs (Compare): Parse string if other object is DateTime
+       regardless of which side the DateTime is on.
 
 2008-08-18  Marek Habersack  <mhabersack@novell.com>
 
index 9049205eee8a7e3235819e3f3d0c1bfee11c027b..2e8d07d5a877106f0de73bde3bc289ee8a5cd167 100644 (file)
@@ -105,6 +105,10 @@ namespace Mono.Data.SqlExpressions {
                                // DateTime is always CultureInfo.InvariantCulture
                 o1 = (IComparable) DateTime.Parse ((string)o1, CultureInfo.InvariantCulture);
                        }
+                       else if (o2 is DateTime && o1 is string && Thread.CurrentThread.CurrentCulture != CultureInfo.InvariantCulture) {
+                               // DateTime is always CultureInfo.InvariantCulture
+                               o1 = (IComparable) DateTime.Parse ((string)o1, CultureInfo.InvariantCulture);
+                       }
 
                        if (o1.GetType () != o2.GetType ())
                                o2 = (IComparable)Convert.ChangeType (o2, o1.GetType ());
index 92268dc93d2cf1aeb5cdd25a940f27c84ed1982f..43d80c254455f7fa347c663f62dab564e65cf647 100644 (file)
@@ -4,10 +4,10 @@
        
 2009-07-23  Adam Wendt  <adam@awendtconsulting.com>
 
-       * DateComparisonTest.cs
-       (TestDateComparisonRight, TestDateComparisonLeft): Test case to
-       check that comparison of date and string works regardless of which
-       side the existing date is.
+       * DateComparisonTest.cs
+       (TestDateComparisonRight, TestDateComparisonLeft): Test case to
+       check that comparison of date and string works regardless of which
+       side the existing date is.
 
 2007-06-06  Nagappan A  <anagappan@novell.com>
 
index cf38d8b90fbbed2afd6d218b7476f655c65a56f9..0364f786614edd3467179760146ce0972ae91264 100644 (file)
@@ -2,6 +2,39 @@ using System;
 using System.Data;
 using NUnit.Framework;
 
+namespace Monotests_Mono.Data.SqlExpressions
+{
+       [TestFixture]   
+       public class DateComparisonTest
+       {
+               private DataSet dataSet;
+
+               [SetUp]
+               public void SetUp()
+               {
+                       dataSet = new DataSet();
+                       dataSet.ReadXml("dateComparisonTest.xml", XmlReadMode.InferSchema);
+               }
+
+               [Test]
+               public void TestDateComparisonRight()
+               {
+                       DataView dataView = new DataView(dataSet.Tables["thing"], "#2009-07-19 00:01:00# = start", "", DataViewRowState.CurrentRows);
+                       Assert.AreEqual (1, dataView.Count);
+               }
+               
+               [Test]
+               public void TestDateComparisonLeft()
+               {
+                       DataView dataView = new DataView(dataSet.Tables["thing"], "start = #2009-07-19 00:01:00#", "", DataViewRowState.CurrentRows);
+                       Assert.AreEqual (1, dataView.Count);
+               }
+       }
+}
+using System;
+using System.Data;
+using NUnit.Framework;
+
 namespace Monotests_Mono.Data.SqlExpressions
 {
        [TestFixture]   
index 265b93de8cfeea2e4a236ef31c5e56fb1f3a259c..2e58aef696ae761651985cbd21b0ac37bc4690cb 100644 (file)
@@ -9,3 +9,14 @@
     <start>2009-08-19 00:01</start>
 </thing>
 </things>
+<?xml version="1.0" encoding="utf-8" ?> 
+<things>
+<thing>
+    <title>bar</title>
+    <start>2009-07-19 00:01</start>
+</thing>
+<thing>
+    <title>foo</title>
+    <start>2009-08-19 00:01</start>
+</thing>
+</things>