jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1126550 - in /jackrabbit/trunk: jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractQueryTest.java jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/sql2/QOMFormatter.java
Date Mon, 23 May 2011 15:53:19 GMT
Author: alexparvulescu
Date: Mon May 23 15:53:19 2011
New Revision: 1126550

URL: http://svn.apache.org/viewvc?rev=1126550&view=rev
Log:
JCR-2939 QueryObjectModel does not generate the corresponding SQL2 Query when dealing with
spaces in the path

Modified:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractQueryTest.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/sql2/QOMFormatter.java

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractQueryTest.java?rev=1126550&r1=1126549&r2=1126550&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractQueryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractQueryTest.java
Mon May 23 15:53:19 2011
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.core.query;
 
+import static javax.jcr.query.Query.JCR_SQL2;
+
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -124,11 +126,11 @@ public class AbstractQueryTest extends A
      * @return the elements of the iterator as an array of Nodes.
      */
     protected Node[] toArray(NodeIterator it) {
-        List nodes = new ArrayList();
+        List<Node> nodes = new ArrayList<Node>();
         while (it.hasNext()) {
             nodes.add(it.nextNode());
         }
-        return (Node[]) nodes.toArray(new Node[nodes.size()]);
+        return nodes.toArray(new Node[nodes.size()]);
     }
 
     /**
@@ -201,22 +203,22 @@ public class AbstractQueryTest extends A
     protected void checkResult(NodeIterator result, Node[] nodes)
             throws RepositoryException {
         // collect paths
-        Set expectedPaths = new HashSet();
-        for (int i = 0; i < nodes.length; i++) {
-            expectedPaths.add(nodes[i].getPath());
+        Set<String> expectedPaths = new HashSet<String>();
+        for (Node n : nodes) {
+            expectedPaths.add(n.getPath());
         }
-        Set resultPaths = new HashSet();
+        Set<String> resultPaths = new HashSet<String>();
         while (result.hasNext()) {
             resultPaths.add(result.nextNode().getPath());
         }
         // check if all expected are in result
-        for (Iterator it = expectedPaths.iterator(); it.hasNext();) {
-            String path = (String) it.next();
+        for (Iterator<String> it = expectedPaths.iterator(); it.hasNext();) {
+            String path = it.next();
             assertTrue(path + " is not part of the result set", resultPaths.contains(path));
         }
         // check result does not contain more than expected
-        for (Iterator it = resultPaths.iterator(); it.hasNext();) {
-            String path = (String) it.next();
+        for (Iterator<String> it = resultPaths.iterator(); it.hasNext();) {
+            String path = it.next();
             assertTrue(path + " is not expected to be part of the result set", expectedPaths.contains(path));
         }
     }
@@ -256,6 +258,11 @@ public class AbstractQueryTest extends A
         }
     }
 
+    protected QueryResult executeSQL2Query(String statement)
+            throws RepositoryException {
+        return qm.createQuery(statement, JCR_SQL2).execute();
+    }
+
     /**
      * Returns a reference to the underlying search index.
      *

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/sql2/QOMFormatter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/sql2/QOMFormatter.java?rev=1126550&r1=1126549&r2=1126550&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/sql2/QOMFormatter.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/sql2/QOMFormatter.java
Mon May 23 15:53:19 2011
@@ -508,8 +508,15 @@ public class QOMFormatter implements Que
         if (isSimpleName(path)) {
             append(path);
         } else {
+            boolean needQuotes = path.contains(" ");
             append("[");
+            if (needQuotes) {
+                append("'");
+            }
             append(path);
+            if (needQuotes) {
+                append("'");
+            }
             append("]");
         }
     }



Mime
View raw message