openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hthom...@apache.org
Subject svn commit: r1513273 - in /openjpa/branches/2.2.1.x: ./ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SQLStoreQuery.java openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TestSQLStoreParamsSubstitution.java
Date Mon, 12 Aug 2013 21:54:55 GMT
Author: hthomann
Date: Mon Aug 12 21:54:55 2013
New Revision: 1513273

URL: http://svn.apache.org/r1513273
Log:
OPENJPA-2376: Escape character in JPQL with parameter substitution generates incorrect SQL
- committed a patch sent to me by Albert Lee - merged changes from 2.1.x.

Added:
    openjpa/branches/2.2.1.x/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TestSQLStoreParamsSubstitution.java
      - copied unchanged from r1513249, openjpa/branches/2.1.x/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TestSQLStoreParamsSubstitution.java
Modified:
    openjpa/branches/2.2.1.x/   (props changed)
    openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SQLStoreQuery.java

Propchange: openjpa/branches/2.2.1.x/
------------------------------------------------------------------------------
  Merged /openjpa/branches/2.1.x:r1513249

Modified: openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SQLStoreQuery.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SQLStoreQuery.java?rev=1513273&r1=1513272&r2=1513273&view=diff
==============================================================================
--- openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SQLStoreQuery.java
(original)
+++ openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SQLStoreQuery.java
Mon Aug 12 21:54:55 2013
@@ -365,6 +365,7 @@ public class SQLStoreQuery
             if (sql.indexOf("?") == -1)
                 return sql;
 
+            sql = sql.replaceAll("\\\\", "\\\\\\\\");
             paramOrder.clear();
             StreamTokenizer tok = new StreamTokenizer(new StringReader(sql));
             tok.resetSyntax();
@@ -396,6 +397,14 @@ public class SQLStoreQuery
                             buf.append(tok.sval);
                             buf.append('\'');
                         }
+//                        // StreamTokenizer can not differentiate the last quoted token
as in ^.*'.*$ and ^.*',*'$
+//                        // need to check the last quote ends with "'" and process accordingly.
+//                        if(endsWithQuote) {
+//                            buf.append('\'');                        	
+//                        } else if (tok.nextToken() != StreamTokenizer.TT_EOF) {
+//                        	tok.pushBack();
+//                            buf.append('\'');                        	
+//                        }
                         break;
                     default:
                         buf.append((char) ttype);



Mime
View raw message