]> source.dussan.org Git - jackcess.git/commitdiff
Don't double quote already quoted identifiers. fixes patch 18
authorJames Ahlborn <jtahlborn@yahoo.com>
Wed, 3 Dec 2014 03:23:51 +0000 (03:23 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Wed, 3 Dec 2014 03:23:51 +0000 (03:23 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@901 f203690c-595d-4dc9-a70b-905162fa7fd2

pom.xml
src/changes/changes.xml
src/main/java/com/healthmarketscience/jackcess/impl/query/QueryImpl.java
src/test/java/com/healthmarketscience/jackcess/query/QueryTest.java

diff --git a/pom.xml b/pom.xml
index 3d83e23c6bd2395655700f93b3c8dc54c466b7d3..3903c71394de6326f9318af80c0805eb5a685b6a 100644 (file)
--- a/pom.xml
+++ b/pom.xml
         <role>Contributed to cookbook.</role>
       </roles>
     </contributor>
+    <contributor>
+      <name>Gabriele Favalessa</name>
+      <roles>
+        <role>Fixed various query generation issues.</role>
+      </roles>
+    </contributor>
   </contributors>
   <issueManagement>
     <system>SourceForge2</system>
index 721e92361d3625b7ceafcdec151593aee0b42958..5137378f74e8d42af3d560cdcf9588529a671405 100644 (file)
@@ -11,6 +11,9 @@
       <action dev="jahlborn" type="fix" system="SourceForge2Patches" issue="17">
         Fix table name quoting for append and make table queries.
       </action>
+      <action dev="jahlborn" type="fix" system="SourceForge2Patches" issue="18">
+        Don't double quote already quoted identifiers.
+      </action>
     </release>
     <release version="2.0.7" date="2014-11-22">
       <action dev="jahlborn" type="fix" system="SourceForge2" issue="111">
index 90032eb56c8efe579b494009b4505b3782100682..a69503258326ac415d0b8a4acc9fba55cb605d36 100644 (file)
@@ -510,7 +510,14 @@ public abstract class QueryImpl implements Query
   protected static StringBuilder toQuotedExpr(StringBuilder builder, 
                                               String expr)
   {
-    return builder.append('[').append(expr).append(']');
+    return (!isQuoted(expr) ? 
+            builder.append('[').append(expr).append(']') :
+            builder.append(expr));
+  }
+
+  protected static boolean isQuoted(String expr) {
+    return ((expr.length() >= 2) && 
+            (expr.charAt(0) == '[') && (expr.charAt(expr.length() - 1) == ']'));
   }
 
   protected static StringBuilder toRemoteDb(StringBuilder builder,
index ade3ec19713c724bde4bf9a42dbe645c72d088d5..65741cc5f2ae9f31b351add471d73eabdb987ec4 100644 (file)
@@ -224,7 +224,7 @@ public class QueryTest extends TestCase
           "UpdateQuery",multiline(
               "PARAMETERS User Name Text;",
               "UPDATE Table1",
-              "SET Table1.col1 = \"foo\", Table1.col2 = [Table2].[col3], [[Table2]].[[col1]] = [User Name]",
+              "SET Table1.col1 = \"foo\", Table1.col2 = [Table2].[col3], [Table2].[col1] = [User Name]",
               "WHERE ((([Table2].[col1]) Is Not Null));"));
       expectedQueries.put(
           "MakeTableQuery",multiline(