details:   https://code.openbravo.com/erp/devel/pi/rev/5e5dd4a8b5c0
changeset: 20224:5e5dd4a8b5c0
user:      Shankar Balachandran <shankar.balachandran <at> openbravo.com>
date:      Sun Apr 28 12:45:45 2013 +0530
summary:   Fixes Issue 0023538: Tab whereclause not resolving properly

Tab whereclause now resolves properly comparations of YesNo (boolean) reference 
columns.Type casted the typedParameter to boolean when substituting the value.

diffstat:

 
modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
 |  50 +++++----
 1 files changed, 27 insertions(+), 23 deletions(-)

diffs (75 lines):

diff -r 186ce27095a7 -r 5e5dd4a8b5c0 
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
       Fri Apr 26 23:54:21 2013 +0200
+++ 
b/modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
       Sun Apr 28 12:45:45 2013 +0530
@@ -1016,7 +1016,11 @@
           // substitute all occurrences of paramater
           localWhereClause = localWhereClause.substring(0, index) + 
getTypedParameterAlias() + " "
               + localWhereClause.substring(index + key.length());
-          typedParameters.add("null".equals(value) ? null : value);
+          if (value.equals("true") || value.equals("false")) {
+            typedParameters.add("null".equals(value) ? null : 
Boolean.valueOf(value.toString()));
+          } else {
+            typedParameters.add("null".equals(value) ? null : value);
+          }
           index = localWhereClause.toLowerCase().indexOf(key.toLowerCase());
         }
       }
@@ -1129,25 +1133,25 @@
   }
 
   protected String getOrderByClausePart(String orderByParam) {
-       // Support for one argument functions
-       String functionPattern = "(.*)\\((.*)\\) (desc|DESC)+";
-       Pattern p = Pattern.compile(functionPattern);
-       Matcher m = p.matcher(orderByParam);
+    // Support for one argument functions
+    String functionPattern = "(.*)\\((.*)\\) (desc|DESC)+";
+    Pattern p = Pattern.compile(functionPattern);
+    Matcher m = p.matcher(orderByParam);
 
-       String localOrderBy = null;
-       String functionName = null;
-       boolean descOrderedFunction = false;
-       if (m.find()) {
-               // If it is a function, retrieve the function name and the 
localOrderBy
-               functionName = m.group(1);
-               localOrderBy = m.group(2);
-               if (m.groupCount() == 3) {
-                       // Check if the property is to be ordered in descending 
order
-                       descOrderedFunction = true;
-               }
-       } else {
-               localOrderBy = orderByParam;
-       }
+    String localOrderBy = null;
+    String functionName = null;
+    boolean descOrderedFunction = false;
+    if (m.find()) {
+      // If it is a function, retrieve the function name and the localOrderBy
+      functionName = m.group(1);
+      localOrderBy = m.group(2);
+      if (m.groupCount() == 3) {
+        // Check if the property is to be ordered in descending order
+        descOrderedFunction = true;
+      }
+    } else {
+      localOrderBy = orderByParam;
+    }
 
     final boolean asc = !localOrderBy.startsWith("-");
     String direction = "";
@@ -1220,10 +1224,10 @@
 
     String orderByClausePart = sb.toString();
     if (functionName != null) {
-       orderByClausePart = functionName + "(" + orderByClausePart + ")";
-       if (descOrderedFunction) {
-               orderByClausePart = orderByClausePart + " desc";
-       }
+      orderByClausePart = functionName + "(" + orderByClausePart + ")";
+      if (descOrderedFunction) {
+        orderByClausePart = orderByClausePart + " desc";
+      }
     }
     return orderByClausePart;
   }

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to