You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by mw...@apache.org on 2023/04/21 13:16:56 UTC

svn commit: r1909325 - in /db/torque/trunk/torque-runtime/src: main/java/org/apache/torque/criteria/Criterion.java test/java/org/apache/torque/criteria/CriterionTest.java

Author: mwriedt
Date: Fri Apr 21 13:16:56 2023
New Revision: 1909325

URL: http://svn.apache.org/viewvc?rev=1909325&view=rev
Log:
- TORQUE-363 added new constructor for Criterion with SqlEnum as second value.

Modified:
    db/torque/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criterion.java
    db/torque/trunk/torque-runtime/src/test/java/org/apache/torque/criteria/CriterionTest.java

Modified: db/torque/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criterion.java
URL: http://svn.apache.org/viewvc/db/torque/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criterion.java?rev=1909325&r1=1909324&r2=1909325&view=diff
==============================================================================
--- db/torque/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criterion.java (original)
+++ db/torque/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criterion.java Fri Apr 21 13:16:56 2023
@@ -164,6 +164,22 @@ public class Criterion implements Serial
     }
 
     /**
+     * Create a new instance without verbatim sql, using a comparison operator
+     * without the need for a right value (like ISNULL, ISNOTNULL, etc.)
+     *
+     * @param lValue the left hand side value of the comparison, not null.
+     *        If this value should be a value from the database,
+     *        the object must implement the
+     *        <code>org.apache.torque.Column</code> interface.
+     * @param comparison the comparison operator, not null.
+     *        If the comparison operator needs 2 values, the
+     *        second value will always be null.
+     */
+    public Criterion(final Object lValue, final SqlEnum comparison)
+    {
+        this(lValue, null, comparison, null, null);
+    }
+    /**
      * Create a new instance without verbatim sql.
      *
      * @param lValue the left hand side value of the comparison, not null.
@@ -174,7 +190,7 @@ public class Criterion implements Serial
      *        If this value should be a value from the database,
      *        the object must implement the
      *        <code>org.apache.torque.Column</code> interface.
-     * @param comparison The comparison operator, not null.
+     * @param comparison the comparison operator, not null.
      */
     public Criterion(final Object lValue, final Object rValue, final SqlEnum comparison)
     {

Modified: db/torque/trunk/torque-runtime/src/test/java/org/apache/torque/criteria/CriterionTest.java
URL: http://svn.apache.org/viewvc/db/torque/trunk/torque-runtime/src/test/java/org/apache/torque/criteria/CriterionTest.java?rev=1909325&r1=1909324&r2=1909325&view=diff
==============================================================================
--- db/torque/trunk/torque-runtime/src/test/java/org/apache/torque/criteria/CriterionTest.java (original)
+++ db/torque/trunk/torque-runtime/src/test/java/org/apache/torque/criteria/CriterionTest.java Fri Apr 21 13:16:56 2023
@@ -90,19 +90,20 @@ public class CriterionTest extends BaseT
     @Test
     public void testIsNullInCriterion()
     {
-        
+        // using null as second value
         Criterion criterion1 = new Criterion(
                 new ColumnImpl("myTable", "myColumn"), null, Criteria.ISNULL);
         assertEquals("myTable.myColumn IS NULL",
                 criterion1.toString());
 
-        // fails and sets "="
-//        Criterion criterion2 = new Criterion(
-//                new ColumnImpl("myTable", "myColumn"), Criteria.ISNULL);
-//        assertEquals("myTable.myColumn IS NULL",
-//                criterion2.toString());
+        // using new constructor without need to define second value
+        Criterion criterion2 = new Criterion(
+                new ColumnImpl("myTable", "myColumn"), Criteria.ISNULL);
+        assertEquals("myTable.myColumn IS NULL",
+                criterion2.toString());
     }
 
+
     /**
      * Tests that a criterion is copied when being anded to a top level
      * criterion.



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