details:   https://code.openbravo.com/erp/devel/pi/rev/415f64b18378
changeset: 24224:415f64b18378
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Fri Aug 08 11:14:59 2014 +0200
summary:   Fixes issue 26681: Filtering in Query Widgets supports any letter 
case

The previous fix was taking from granted that the hql order by clause was going 
to be lowercase.

It was also handling a case that was never going to happen: a HQL query with a 
limit clause (hql does not support limit clauses).

diffstat:

 
modules/org.openbravo.client.querylist/src/org/openbravo/client/querylist/QueryListDataSource.java
 |  13 +++------
 1 files changed, 5 insertions(+), 8 deletions(-)

diffs (31 lines):

diff -r e5b0eccfb86c -r 415f64b18378 
modules/org.openbravo.client.querylist/src/org/openbravo/client/querylist/QueryListDataSource.java
--- 
a/modules/org.openbravo.client.querylist/src/org/openbravo/client/querylist/QueryListDataSource.java
        Fri Aug 08 00:16:26 2014 +0200
+++ 
b/modules/org.openbravo.client.querylist/src/org/openbravo/client/querylist/QueryListDataSource.java
        Fri Aug 08 11:14:59 2014 +0200
@@ -314,7 +314,7 @@
     if (sortBy.contains(",")) {
       fieldList = sortBy.split(",");
     }
-    if (hqlString.contains("order by")) {
+    if (hqlString.toLowerCase().contains("order by")) {
       if (fieldList == null) {
         sortByClause = sortBy.startsWith("-") ? sortBy.substring(1, 
sortBy.length()) + " desc "
             : sortBy;
@@ -326,14 +326,11 @@
               + " desc " : sortByClause.concat(field);
         }
       }
-      hqlString = hqlString.replace("order by", "order by " + sortByClause + 
",");
+      int sortByIndex = hqlString.toLowerCase().indexOf("order by");
+      hqlString = hqlString.substring(0, sortByIndex + "order by".length() + 
1) + sortByClause
+          + "," + hqlString.substring(sortByIndex + "order by".length() + 1);
     } else {
-      // if limit is present in the hql, append order by before it
-      if (hqlString.contains("limit")) {
-        hqlString.replace("limit", sortByClause + " limit");
-      } else {
-        hqlString = hqlString.concat(" order by " + sortByClause);
-      }
+      hqlString = hqlString.concat(" order by " + sortByClause);
     }
     return hqlString;
   }

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to