db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1333013 - in /db/torque/torque4/trunk/torque-runtime/src: main/java/org/apache/torque/criteria/ main/java/org/apache/torque/sql/objectbuilder/ main/java/org/apache/torque/sql/whereclausebuilder/ test/java/org/apache/torque/sql/
Date Wed, 02 May 2012 12:32:46 GMT
Author: tfischer
Date: Wed May  2 12:32:45 2012
New Revision: 1333013

URL: http://svn.apache.org/viewvc?rev=1333013&view=rev
Log:
TORQUE-142 honor CURRENT_TIMESTAMP sql expression in runtime

Modified:
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/SqlEnum.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/objectbuilder/ObjectOrColumnPsPartBuilder.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/whereclausebuilder/CurrentDateTimePsPartBuilder.java
    db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/sql/SqlBuilderTest.java

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java?rev=1333013&r1=1333012&r2=1333013&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java
Wed May  2 12:32:45 2012
@@ -121,6 +121,9 @@ public class Criteria
     /** "CURRENT_TIME" ANSI SQL function */
     public static final SqlEnum CURRENT_TIME = SqlEnum.CURRENT_TIME;
 
+    /** "CURRENT_TIMESTAMP" ANSI SQL function */
+    public static final SqlEnum CURRENT_TIMESTAMP = SqlEnum.CURRENT_TIMESTAMP;
+
     /** "LEFT JOIN" SQL statement */
     public static final JoinType LEFT_JOIN = JoinType.LEFT_JOIN;
 

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/SqlEnum.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/SqlEnum.java?rev=1333013&r1=1333012&r2=1333013&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/SqlEnum.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/SqlEnum.java
Wed May  2 12:32:45 2012
@@ -118,6 +118,9 @@ public final class SqlEnum implements ja
     /** SQL Expression "CURRENT_TIME". */
     public static final SqlEnum CURRENT_TIME =
         new SqlEnum("CURRENT_TIME");
+    /** SQL Expression "CURRENT_TIMESTAMP". */
+    public static final SqlEnum CURRENT_TIMESTAMP =
+            new SqlEnum("CURRENT_TIMESTAMP");
     /** SQL Expression " ON ". */
     public static final SqlEnum ON =
         new SqlEnum(" ON ");

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/objectbuilder/ObjectOrColumnPsPartBuilder.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/objectbuilder/ObjectOrColumnPsPartBuilder.java?rev=1333013&r1=1333012&r2=1333013&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/objectbuilder/ObjectOrColumnPsPartBuilder.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/objectbuilder/ObjectOrColumnPsPartBuilder.java
Wed May  2 12:32:45 2012
@@ -96,7 +96,9 @@ public class ObjectOrColumnPsPartBuilder
         if (toBuildFrom.equals(
                 SqlEnum.CURRENT_DATE)
                 || toBuildFrom.equals(
-                        SqlEnum.CURRENT_TIME))
+                        SqlEnum.CURRENT_TIME)
+                || toBuildFrom.equals(
+                        SqlEnum.CURRENT_TIMESTAMP))
         {
             result.getSql().append(toBuildFrom.toString());
             return result;

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/whereclausebuilder/CurrentDateTimePsPartBuilder.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/whereclausebuilder/CurrentDateTimePsPartBuilder.java?rev=1333013&r1=1333012&r2=1333013&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/whereclausebuilder/CurrentDateTimePsPartBuilder.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/whereclausebuilder/CurrentDateTimePsPartBuilder.java
Wed May  2 12:32:45 2012
@@ -66,7 +66,9 @@ public class CurrentDateTimePsPartBuilde
         if (whereClauseExpression.getOperator().equals(
                         SqlEnum.CURRENT_DATE)
                 || whereClauseExpression.getOperator().equals(
-                        SqlEnum.CURRENT_TIME))
+                        SqlEnum.CURRENT_TIME)
+                || whereClauseExpression.getOperator().equals(
+                        SqlEnum.CURRENT_TIMESTAMP))
             {
                 return true;
             }

Modified: db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/sql/SqlBuilderTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/sql/SqlBuilderTest.java?rev=1333013&r1=1333012&r2=1333013&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/sql/SqlBuilderTest.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/sql/SqlBuilderTest.java
Wed May  2 12:32:45 2012
@@ -1390,6 +1390,18 @@ public class SqlBuilderTest extends Base
         assertEquals(0, query.getPreparedStatementReplacements().size());
     }
 
+    public void testCurrentTimestamp() throws Exception
+    {
+        Criteria criteria = new Criteria();
+        criteria.addSelectColumn(new ColumnImpl("table.column"));
+        criteria.where(new ColumnImpl("column"), Criteria.CURRENT_TIMESTAMP);
+        Query query = SqlBuilder.buildQuery(criteria);
+        assertEquals("SELECT table.column FROM table "
+                + "WHERE column=CURRENT_TIMESTAMP",
+            query.toString());
+        assertEquals(0, query.getPreparedStatementReplacements().size());
+    }
+
     public void testObjectKey() throws Exception
     {
         Criteria criteria = new Criteria();



---------------------------------------------------------------------
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