Author: hthomann
Date: Mon Aug 12 22:02:58 2013
New Revision: 1513276

URL: http://svn.apache.org/r1513276
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/trunk/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/trunk/   (props changed)
    
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SQLStoreQuery.java

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

Modified: 
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SQLStoreQuery.java
URL: 
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SQLStoreQuery.java?rev=1513276&r1=1513275&r2=1513276&view=diff
==============================================================================
--- 
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SQLStoreQuery.java
 (original)
+++ 
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SQLStoreQuery.java
 Mon Aug 12 22:02:58 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);


Reply via email to