Return-Path: X-Original-To: apmail-openjpa-commits-archive@www.apache.org Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1170110107 for ; Mon, 12 Aug 2013 21:55:17 +0000 (UTC) Received: (qmail 63188 invoked by uid 500); 12 Aug 2013 21:55:17 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 63165 invoked by uid 500); 12 Aug 2013 21:55:16 -0000 Mailing-List: contact commits-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list commits@openjpa.apache.org Received: (qmail 63158 invoked by uid 99); 12 Aug 2013 21:55:16 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Aug 2013 21:55:16 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Aug 2013 21:55:15 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id C3EAA23888CD; Mon, 12 Aug 2013 21:54:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@openjpa.apache.org From: hthomann@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130812215455.C3EAA23888CD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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);