db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r421692 - in /db/torque/runtime/trunk/src: java/org/apache/torque/util/Criteria.java test/org/apache/torque/util/CriteriaTest.java
Date Thu, 13 Jul 2006 19:44:41 GMT
Author: tv
Date: Thu Jul 13 12:44:40 2006
New Revision: 421692

URL: http://svn.apache.org/viewvc?rev=421692&view=rev
Log:
Fixed Criteria.andDate() methods to call getTime() like the addDate
methods do. Added a test case to check this. Thanks to Federico Fissore
for the Criteria patch. Fixes TORQUE-42.

Modified:
    db/torque/runtime/trunk/src/java/org/apache/torque/util/Criteria.java
    db/torque/runtime/trunk/src/test/org/apache/torque/util/CriteriaTest.java

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/util/Criteria.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/util/Criteria.java?rev=421692&r1=421691&r2=421692&view=diff
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/util/Criteria.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/util/Criteria.java Thu Jul 13 12:44:40
2006
@@ -2309,7 +2309,7 @@
      */
     public Criteria andDate(String column, int year, int month, int date)
     {
-        and(column, new GregorianCalendar(year, month, date));
+        and(column, new GregorianCalendar(year, month, date).getTime());
         return this;
     }
 
@@ -2334,7 +2334,7 @@
     public Criteria andDate(String column, int year, int month, int date,
             SqlEnum comparison)
     {
-        and(column, new GregorianCalendar(year, month, date), comparison);
+        and(column, new GregorianCalendar(year, month, date).getTime(), comparison);
         return this;
     }
 

Modified: db/torque/runtime/trunk/src/test/org/apache/torque/util/CriteriaTest.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/test/org/apache/torque/util/CriteriaTest.java?rev=421692&r1=421691&r2=421692&view=diff
==============================================================================
--- db/torque/runtime/trunk/src/test/org/apache/torque/util/CriteriaTest.java (original)
+++ db/torque/runtime/trunk/src/test/org/apache/torque/util/CriteriaTest.java Thu Jul 13 12:44:40
2006
@@ -310,6 +310,31 @@
     }
 
     /**
+     * testcase for andDate()
+     * issue TORQUE-42
+     */
+    public void testAndDate()
+    {
+        Criteria c = new Criteria();
+        c.addDate("TABLE.DATE_COLUMN", 2003, 0, 22, Criteria.GREATER_THAN);
+        c.andDate("TABLE.DATE_COLUMN", 2004, 0, 22, Criteria.LESS_THAN);
+
+        String expect = "SELECT  FROM TABLE WHERE (TABLE.DATE_COLUMN>'20030122000000'
AND TABLE.DATE_COLUMN<'20040122000000')";
+
+        String result = null;
+        try
+        {
+            result = BasePeer.createQueryString(c);
+        }
+        catch (TorqueException e)
+        {
+            e.printStackTrace();
+            fail("TorqueException thrown in BasePeer.createQueryString()");
+        }
+        assertEquals(expect, result);
+    }
+
+    /**
      * testcase for add(Date)
      */
     public void testDateAdd()



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message