db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1211142 - in /db/torque/torque4/trunk/torque-runtime/src: main/java/org/apache/torque/sql/SqlBuilder.java main/java/org/apache/torque/util/Criteria.java test/java/org/apache/torque/sql/SqlBuilderTest.java
Date Tue, 06 Dec 2011 21:04:03 GMT
Author: tfischer
Date: Tue Dec  6 21:04:03 2011
New Revision: 1211142

URL: http://svn.apache.org/viewvc?rev=1211142&view=rev
Log:
Also ignore case in order by if ignoreCase in Criteria is set to true

Modified:
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/SqlBuilder.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.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/sql/SqlBuilder.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/SqlBuilder.java?rev=1211142&r1=1211141&r2=1211142&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/SqlBuilder.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/SqlBuilder.java
Tue Dec  6 21:04:03 2011
@@ -354,7 +354,7 @@ public final class SqlBuilder
                     || (columnMap.getType() instanceof String
                         && sqlExpression.indexOf('(') == -1))
             {
-                if (orderBy.isIgnoreCase())
+                if (orderBy.isIgnoreCase() || crit.isIgnoreCase())
                 {
                     orderByClause.add(
                             db.ignoreCaseInOrderBy(sqlExpression)

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.java?rev=1211142&r1=1211141&r2=1211142&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.java
Tue Dec  6 21:04:03 2011
@@ -1818,7 +1818,8 @@ public class Criteria implements Seriali
     }
 
     /**
-     * Sets ignore case.
+     * Sets whether case should be ignored in where clauses and order by
+     * whenever String columns are encountered.
      *
      * @param b True if case should be ignored.
      * @return A modified Criteria object.
@@ -1830,7 +1831,8 @@ public class Criteria implements Seriali
     }
 
     /**
-     * Is ignore case on or off?
+     * Returns whether case should be ignored in where clauses and order by
+     * whenever String columns are encountered.
      *
      * @return True if case is ignored.
      */

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=1211142&r1=1211141&r2=1211142&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
Tue Dec  6 21:04:03 2011
@@ -171,7 +171,35 @@ public class SqlBuilderTest extends Base
                 query.toString());
     }
 
-    public void testOrderByDescendingIgnoreCase() throws Exception
+    public void testOrderByAscendingIgnoreCaseStringInCriteria()
+            throws Exception
+    {
+        Criteria criteria = new Criteria();
+        criteria.addAscendingOrderByColumn(stringColumnMap);
+        criteria.setIgnoreCase(true);
+
+        Query query = SqlBuilder.buildQuery(criteria);
+        assertEquals(
+                "SELECT UPPER(TABLE.COLUMN1) FROM TABLE "
+                    + "ORDER BY UPPER(TABLE.COLUMN1) ASC",
+                query.toString());
+    }
+
+    public void testOrderByAscendingIgnoreCaseIntegerInCriteria()
+            throws Exception
+    {
+        Criteria criteria = new Criteria();
+        criteria.addAscendingOrderByColumn(integerColumnMap);
+        criteria.setIgnoreCase(true);
+
+        Query query = SqlBuilder.buildQuery(criteria);
+        assertEquals(
+                "SELECT TABLE.COLUMN4 FROM TABLE "
+                    + "ORDER BY TABLE.COLUMN4 ASC",
+                query.toString());
+    }
+
+    public void testOrderByDescendingIgnoreCaseString() throws Exception
     {
         Criteria criteria = new Criteria();
         criteria.addDescendingOrderByColumn(stringColumnMap, true);
@@ -195,6 +223,34 @@ public class SqlBuilderTest extends Base
                 query.toString());
     }
 
+    public void testOrderByDescendingIgnoreCaseStringInCriteria()
+            throws Exception
+    {
+        Criteria criteria = new Criteria();
+        criteria.addDescendingOrderByColumn(stringColumnMap);
+        criteria.setIgnoreCase(true);
+
+        Query query = SqlBuilder.buildQuery(criteria);
+        assertEquals(
+                "SELECT UPPER(TABLE.COLUMN1) FROM TABLE "
+                    + "ORDER BY UPPER(TABLE.COLUMN1) DESC",
+                query.toString());
+    }
+
+    public void testOrderByDescendingIgnoreCaseIntegerInCriteria()
+            throws Exception
+    {
+        Criteria criteria = new Criteria();
+        criteria.addDescendingOrderByColumn(integerColumnMap);
+        criteria.setIgnoreCase(true);
+
+        Query query = SqlBuilder.buildQuery(criteria);
+        assertEquals(
+                "SELECT TABLE.COLUMN4 FROM TABLE "
+                    + "ORDER BY TABLE.COLUMN4 DESC",
+                query.toString());
+    }
+
     public void testAlias() 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