jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1179124 - in /jackrabbit/trunk: jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/search/SearchResourceImpl.java jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/query/QueryTest.java
Date Wed, 05 Oct 2011 09:40:32 GMT
Author: alexparvulescu
Date: Wed Oct  5 09:40:29 2011
New Revision: 1179124

URL: http://svn.apache.org/viewvc?rev=1179124&view=rev
Log:
JCR-3089 javax.jcr.RepositoryException when a JOIN SQL2 query is send via Davex and has results

Modified:
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/search/SearchResourceImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/query/QueryTest.java

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/search/SearchResourceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/search/SearchResourceImpl.java?rev=1179124&r1=1179123&r2=1179124&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/search/SearchResourceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/search/SearchResourceImpl.java
Wed Oct  5 09:40:29 2011
@@ -241,9 +241,16 @@ public class SearchResourceImpl implemen
                 values.add(rv.getValue(row));
             }
 
-            // get the path for the first selector and build
-            // a webdav compliant resource path of it.
-            String itemPath = row.getPath();
+            /*
+             * get the path for the first selector and build a webdav compliant
+             * resource path based on it.
+             * 
+             * Use Row#getPath(String) which works for both simple rows and join
+             * rows (in contrast to Row#getPath()).
+             * 
+             * see also https://issues.apache.org/jira/browse/JCR-3089
+             */
+            final String itemPath = row.getPath(sn.get(0));
             // create a new ms-response for this row of the result set
             DavResourceLocator loc = locator.getFactory().createResourceLocator(locator.getPrefix(),
locator.getWorkspacePath(), itemPath, false);
             String href = loc.getHref(true);

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/query/QueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/query/QueryTest.java?rev=1179124&r1=1179123&r2=1179124&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/query/QueryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/query/QueryTest.java
Wed Oct  5 09:40:29 2011
@@ -22,6 +22,8 @@ import javax.jcr.RepositoryException;
 import javax.jcr.NodeIterator;
 import javax.jcr.Node;
 import javax.jcr.NamespaceRegistry;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryResult;
 import java.util.List;
 import java.util.ArrayList;
 
@@ -55,7 +57,7 @@ public class QueryTest extends AbstractQ
         }
 
         Node n = testRootNode.addNode("spiTest:node");
-        testRootNode.save();
+        superuser.save();
 
         for (int i = 0; i < 10; i++) {
             String prefix = defaultPrefix + i;
@@ -63,4 +65,42 @@ public class QueryTest extends AbstractQ
             executeXPathQuery(superuser, testPath + "/" + prefix + ":node", new Node[]{n});
         }
     }
+
+    /**
+     * https://issues.apache.org/jira/browse/JCR-3089
+     */
+    public void testSQL2Simple() throws Exception {
+        Query q = qm.createQuery("SELECT * FROM [nt:unstructured]",
+                Query.JCR_SQL2);
+        QueryResult r = q.execute();
+        assertTrue(r.getNodes().hasNext());
+    }
+
+    /**
+     * https://issues.apache.org/jira/browse/JCR-2543
+     */
+    public void testSQL2Limit() throws Exception {
+        Query q = qm.createQuery("SELECT * FROM [nt:unstructured]",
+                Query.JCR_SQL2);
+        q.setLimit(1);
+        QueryResult r = q.execute();
+
+        NodeIterator it = r.getNodes();
+        assertTrue(it.hasNext());
+        it.next();
+        assertFalse(it.hasNext());
+    }
+
+    /**
+     * https://issues.apache.org/jira/browse/JCR-3089
+     */
+    public void testSQL2Join() throws Exception {
+        // he query is not supposed to return anything, it will just check that
+        // the back and forth between the client and the server works
+        Query q = qm
+                .createQuery(
+                        "SELECT * FROM [nt:unstructured] AS a INNER JOIN [nt:unstructured]
AS b ON b.[refid] = a.[jcr:uuid]",
+                        Query.JCR_SQL2);
+        assertNotNull(q.execute());
+    }
 }



Mime
View raw message