openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fa...@apache.org
Subject svn commit: r659027 - in /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps: All.java Any.java Distinct.java UnaryOp.java
Date Thu, 22 May 2008 07:30:25 GMT
Author: fancy
Date: Thu May 22 00:30:25 2008
New Revision: 659027

URL: http://svn.apache.org/viewvc?rev=659027&view=rev
Log:
OPENJPA-607 Extraneous "( )" on DISTINCT, ALL, ANY results in SQL syntax errors on some database
systems

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/All.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Any.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Distinct.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/UnaryOp.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/All.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/All.java?rev=659027&r1=659026&r2=659027&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/All.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/All.java
Thu May 22 00:30:25 2008
@@ -27,7 +27,7 @@
     extends UnaryOp {
 
     public All(Val val) {
-        super(val);
+        super(val, true);
     }
 
     protected String getOperator() {

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Any.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Any.java?rev=659027&r1=659026&r2=659027&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Any.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Any.java
Thu May 22 00:30:25 2008
@@ -27,7 +27,7 @@
     extends UnaryOp {
 
     public Any(Val val) {
-        super(val);
+        super(val, true);
     }
 
     protected String getOperator() {

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Distinct.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Distinct.java?rev=659027&r1=659026&r2=659027&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Distinct.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Distinct.java
Thu May 22 00:30:25 2008
@@ -30,7 +30,7 @@
     extends UnaryOp {
 
     public Distinct(Val val) {
-        super(val);
+        super(val, true);
     }
 
     public ExpState initialize(Select sel, ExpContext ctx, int flags) {
@@ -41,18 +41,4 @@
     protected String getOperator() {
         return "DISTINCT";
     }
-    
-
-    public void appendTo(Select sel, ExpContext ctx, ExpState state, 
-        SQLBuffer sql, int index) {
-        if (sel.getConfiguration().getDBDictionaryInstance().platform.indexOf(
-            "Informix") > -1) {
-            sql.append(getOperator());
-            sql.append(" ");
-            getValue().appendTo(sel, ctx, state, sql, 0);
-            sql.addCastForParam(getOperator(), getValue());
-        }
-        else
-            super.appendTo(sel, ctx, state, sql, index);
-    }
 }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/UnaryOp.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/UnaryOp.java?rev=659027&r1=659026&r2=659027&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/UnaryOp.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/UnaryOp.java
Thu May 22 00:30:25 2008
@@ -39,6 +39,7 @@
     private final Val _val;
     private ClassMetaData _meta = null;
     private Class _cast = null;
+    private boolean _noParen = false;
 
     /**
      * Constructor. Provide the value to operate on.
@@ -46,6 +47,11 @@
     public UnaryOp(Val val) {
         _val = val;
     }
+    
+    public UnaryOp(Val val, boolean noParen) {
+        _val = val;
+        _noParen = noParen;
+    }
 
     protected Val getValue() {
         return _val;
@@ -123,10 +129,11 @@
     public void appendTo(Select sel, ExpContext ctx, ExpState state, 
         SQLBuffer sql, int index) {
         sql.append(getOperator());
-        sql.append("(");
+        sql.append(_noParen ? " " : "(");
         _val.appendTo(sel, ctx, state, sql, 0);
         sql.addCastForParam(getOperator(), _val);
-        sql.append(")");
+        if (!_noParen)
+            sql.append(")");
     }
 
     /**



Mime
View raw message