mpoeschl 2003/01/22 13:44:03
Modified: src/java/org/apache/torque/util Criteria.java
src/test/org/apache/torque/util CriteriaTest.java
xdocs changes.xml
Log:
o TRQ18: Criteria.addDate is broken
o unit test added too ;-)
Revision Changes Path
1.38 +8 -5
jakarta-turbine-torque/src/java/org/apache/torque/util/Criteria.java
Index: Criteria.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/util/Criteria.java,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- Criteria.java 9 Jan 2003 17:46:21 -0000 1.37
+++ Criteria.java 22 Jan 2003 21:44:02 -0000 1.38
@@ -1278,13 +1278,14 @@
*
* @param column A String value to use as column.
* @param year An int with the year.
- * @param month An int with the month.
+ * @param month An int with the month. Month value is 0-based.
+ * e.g., 0 for January
* @param date An int with the date.
* @return A modified Criteria object.
*/
public Criteria addDate(String column, int year, int month, int date)
{
- add(column, new GregorianCalendar(year, month, date));
+ add(column, new GregorianCalendar(year, month, date).getTime());
return this;
}
@@ -1300,7 +1301,8 @@
*
* @param column The column to run the comparison on
* @param year An int with the year.
- * @param month An int with the month.
+ * @param month An int with the month. Month value is 0-based.
+ * e.g., 0 for January
* @param date An int with the date.
* @param comparison String describing how to compare the column with
* the value
@@ -1309,7 +1311,8 @@
public Criteria addDate(String column, int year, int month, int date,
SqlEnum comparison)
{
- add(column, new GregorianCalendar(year, month, date), comparison);
+ add(column, new GregorianCalendar(year, month, date).getTime(),
+ comparison);
return this;
}
1.16 +22 -2
jakarta-turbine-torque/src/test/org/apache/torque/util/CriteriaTest.java
Index: CriteriaTest.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-torque/src/test/org/apache/torque/util/CriteriaTest.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- CriteriaTest.java 28 Nov 2002 16:32:36 -0000 1.15
+++ CriteriaTest.java 22 Jan 2003 21:44:03 -0000 1.16
@@ -312,6 +312,27 @@
assertEquals("TABLE.COLUMN=1", cc.toString());
}
+ public void testAddDate()
+ {
+ Criteria c = new Criteria();
+ c.addDate("TABLE.DATE_COLUMN", 2003, 0, 22);
+
+ String expect = "SELECT FROM TABLE WHERE
TABLE.DATE_COLUMN='20030122000000'";
+
+ String result = null;
+ try
+ {
+ result = BasePeer.createQueryString(c);
+ }
+ catch (TorqueException e)
+ {
+ e.printStackTrace();
+ fail("TorqueException thrown in BasePeer.createQueryString()");
+ }
+ System.out.println(result);
+ assertEquals(expect, result);
+ }
+
public void testCurrentDate()
{
Criteria c = new Criteria()
@@ -332,7 +353,6 @@
}
assertEquals(expect,result);
-
}
public void testCountAster()
1.65 +3 -0 jakarta-turbine-torque/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-torque/xdocs/changes.xml,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- changes.xml 18 Jan 2003 14:51:34 -0000 1.64
+++ changes.xml 22 Jan 2003 21:44:03 -0000 1.65
@@ -44,6 +44,9 @@
<p>
<ul>
<li>
+ TRQ18: Criteria.addDate is broken
+ </li>
+ <li>
TRQ19: recursive external schemas fail
</li>
<li>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>