db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r534001 - in /db/torque: runtime/trunk/src/java/org/apache/torque/util/BasePeer.java runtime/trunk/src/java/org/apache/torque/util/LargeSelect.java test/trunk/test-project/src/java/org/apache/torque/DataTest.java
Date Tue, 01 May 2007 10:46:06 GMT
Author: tv
Date: Tue May  1 03:46:05 2007
New Revision: 534001

URL: http://svn.apache.org/viewvc?view=rev&rev=534001
Log:
Added the call to BasePeer.correctBooleans() to LargeSelect.
Fixed the handling of unqualified column names in BasePeer.correctBooleans(),
Gracefully handle the case of a defaultTableMap==null,
Added testCases to verify the behaviour,
Fixes TORQUE-92

Modified:
    db/torque/runtime/trunk/src/java/org/apache/torque/util/BasePeer.java
    db/torque/runtime/trunk/src/java/org/apache/torque/util/LargeSelect.java
    db/torque/test/trunk/test-project/src/java/org/apache/torque/DataTest.java

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/util/BasePeer.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/util/BasePeer.java?view=diff&rev=534001&r1=534000&r2=534001
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/util/BasePeer.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/util/BasePeer.java Tue May  1 03:46:05
2007
@@ -1530,11 +1530,11 @@
                         tableMap = databaseMap.getTable(tableName);
                     }
                 }
-                if (tableMap == null)
-                {
-                    // no description of table available, do not modify anything
-                    break;
-                }
+            }
+            if (tableMap == null)
+            {
+                // no description of table available, do not modify anything
+                continue;
             }
 
             ColumnMap columnMap = tableMap.getColumn(columnName);

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/util/LargeSelect.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/util/LargeSelect.java?view=diff&rev=534001&r1=534000&r2=534001
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/util/LargeSelect.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/util/LargeSelect.java Tue May  1 03:46:05
2007
@@ -740,6 +740,15 @@
                     criteria.setLimit(blockBegin + memoryLimit + 1);
                 }
             }
+
+            /* 
+             * Fix criterions relating to booleanint or booleanchar columns
+             * The defaultTableMap parameter in this call is null because we have
+             * no default peer class inside LargeSelect. This means that all
+             * columns not fully qualified will not be modified.
+             */
+            BasePeer.correctBooleans(criteria, null);
+            
             query = BasePeer.createQueryString(criteria);
 
             // Get a connection to the db.

Modified: db/torque/test/trunk/test-project/src/java/org/apache/torque/DataTest.java
URL: http://svn.apache.org/viewvc/db/torque/test/trunk/test-project/src/java/org/apache/torque/DataTest.java?view=diff&rev=534001&r1=534000&r2=534001
==============================================================================
--- db/torque/test/trunk/test-project/src/java/org/apache/torque/DataTest.java (original)
+++ db/torque/test/trunk/test-project/src/java/org/apache/torque/DataTest.java Tue May  1
03:46:05 2007
@@ -569,7 +569,45 @@
         assertTrue("Primary key of data set should be f1 but is "
                 + booleanCheck.getTestKey().trim(),
                 "f1".equals(booleanCheck.getTestKey().trim()));
+        
+        // check whether booleans are replaced with unqualified columns
+        criteria.clear();
+        criteria.add("bint_value", true);
+        criteria.add("bchar_value", true);
+        
+        BooleanCheckPeer.correctBooleans(criteria);
 
+        Criteria.Criterion criterionInt = criteria.getCriterion("bint_value");
+        Object intValue = criterionInt.getValue();
+
+        assertTrue("The boolean value should be an instance of Integer",
+                intValue instanceof Integer);
+        
+        Criteria.Criterion criterionChar = criteria.getCriterion("bchar_value");
+        Object charValue = criterionChar.getValue();
+
+        assertTrue("The boolean value should be an instance of String",
+                charValue instanceof String);
+        
+        // check whether booleans are left alone with unqualified columns and 
+        // no table map
+        criteria.clear();
+        criteria.add("bint_value", true);
+        criteria.add("bchar_value", true);
+        
+        BasePeer.correctBooleans(criteria, null);
+
+        Criteria.Criterion criterionBool1 = criteria.getCriterion("bint_value");
+        Object boolValue1 = criterionBool1.getValue();
+
+        assertTrue("The boolean value should be an instance of Boolean",
+               boolValue1 instanceof Boolean);
+        
+        Criteria.Criterion criterionBool2 = criteria.getCriterion("bchar_value");
+        Object boolValue2 = criterionBool2.getValue();
+
+        assertTrue("The boolean value should be an instance of Boolean",
+               boolValue2 instanceof Boolean);
     }
 
     /**



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