jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1561719 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java
Date Mon, 27 Jan 2014 16:15:20 GMT
Author: alexparvulescu
Date: Mon Jan 27 16:15:19 2014
New Revision: 1561719

URL: http://svn.apache.org/r1561719
Log:
OAK-1354 Valid Query for mixin Type in JCR 2.x fails in Oak


Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java?rev=1561719&r1=1561718&r2=1561719&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java
Mon Jan 27 16:15:19 2014
@@ -870,6 +870,12 @@ public class SQL2Parser {
             }
             columns.add(factory.column(selectorName, propertyName, columnName));
         }
+
+        if (columns.isEmpty()) {
+            // OAK-1354, inject the selector name
+            columns.add(factory
+                    .column(selectorName, selectorName, selectorName));
+        }
     }
 
     private void parseComment() throws ParseException {

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java?rev=1561719&r1=1561718&r2=1561719&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java
Mon Jan 27 16:15:19 2014
@@ -25,6 +25,8 @@ import static org.junit.Assert.assertFal
 import static org.junit.Assert.fail;
 
 import java.io.ByteArrayInputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.NoSuchElementException;
@@ -35,6 +37,7 @@ import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.ValueFactory;
+import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.query.Query;
 import javax.jcr.query.QueryManager;
@@ -43,6 +46,7 @@ import javax.jcr.query.Row;
 import javax.jcr.query.RowIterator;
 
 import org.apache.jackrabbit.commons.JcrUtils;
+import org.apache.jackrabbit.commons.cnd.CndImporter;
 import org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest;
 import org.apache.jackrabbit.oak.jcr.NodeStoreFixture;
 import org.junit.Ignore;
@@ -542,4 +546,31 @@ public class QueryTest extends AbstractR
         assertFalse(ni.hasNext());
     }
 
+    @Test
+    public void testOak1354() throws Exception {
+        Session session = createAdminSession();
+        NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
+
+        if (!manager.hasNodeType("mymixinOak1354")) {
+            StringBuilder defs = new StringBuilder();
+            defs.append("[mymixinOak1354]\n");
+            defs.append("  mixin");
+            Reader cndReader = new InputStreamReader(new ByteArrayInputStream(defs.toString().getBytes()));
+            CndImporter.registerNodeTypes(cndReader, session);
+        }
+        Node p = session.getRootNode().addNode("one");
+        p.addMixin("mymixinOak1354");
+        session.save();
+
+        Query q = session.getWorkspace().getQueryManager()
+                .createQuery("SELECT * FROM [mymixinOak1354]", Query.JCR_SQL2);
+        QueryResult qr = q.execute();
+
+        NodeIterator ni = qr.getNodes();
+        assertTrue(ni.hasNext());
+        Node n = ni.nextNode();
+        assertEquals("/one", n.getPath());
+        assertFalse(ni.hasNext());
+    }
+
 }



Mime
View raw message