Fixes issue 25190: Error when searching for characters like ß, in grid view
authorAugusto Mauch <augusto.mauch@openbravo.com>
Thu, 13 Mar 2014 19:04:19 +0100
changeset 22708 eb415e9bc94f
parent 22707 0630b904462c
child 22709 31ec6d0191e3
Fixes issue 25190: Error when searching for characters like ß, in grid view

This happened because when a text field was filtered ignoring the case, the left part of the expression was uppercased using a database method while the right part was uppercased using the String.toUpperCase() java method.
modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
--- a/modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java	Thu Mar 13 18:44:57 2014 +0100
+++ b/modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java	Thu Mar 13 19:04:19 2014 +0100
@@ -644,11 +644,10 @@
       }
     }
 
+    String alias = getTypedParameterAlias();
     if (ignoreCase(property, operator)) {
-      localValue = localValue.toString().toUpperCase();
+      alias = "upper(" + alias + ")";
     }
-
-    final String alias = getTypedParameterAlias();
     String clause;
     if (isLike(operator)) {
       clause = alias + " escape '" + ESCAPE_CHAR + "' ";
@@ -691,12 +690,12 @@
     if (isLike(operator)) {
       if (operator.equals(OPERATOR_INOTCONTAINS) || operator.equals(OPERATOR_ICONTAINS)
           || operator.equals(OPERATOR_CONTAINSFIELD)) {
-        return "%" + escapeLike(value.toString().toUpperCase()).replaceAll(" ", "%") + "%";
+        return "%" + escapeLike(value.toString()).replaceAll(" ", "%") + "%";
       } else if (operator.equals(OPERATOR_NOTCONTAINS) || operator.equals(OPERATOR_CONTAINS)) {
         return "%" + escapeLike(value.toString()).replaceAll(" ", "%") + "%";
       } else if (operator.equals(OPERATOR_INOTSTARTSWITH) || operator.equals(OPERATOR_ISTARTSWITH)
           || operator.equals(OPERATOR_STARTSWITHFIELD)) {
-        return escapeLike(value.toString().toUpperCase()).replaceAll(" ", "%") + "%";
+        return escapeLike(value.toString()).replaceAll(" ", "%") + "%";
       } else if (operator.equals(OPERATOR_NOTSTARTSWITH) || operator.equals(OPERATOR_STARTSWITH)) {
         return escapeLike(value.toString()).replaceAll(" ", "%") + "%";
       } else {