jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1537082 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/OrImpl.java oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java
Date Wed, 30 Oct 2013 13:37:46 GMT
Author: thomasm
Date: Wed Oct 30 13:37:45 2013
New Revision: 1537082

URL: http://svn.apache.org/r1537082
Log:
OAK-1128 Conditions of the form "(x=1 or x=2) or y=3" are not processed correctly

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/OrImpl.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/ast/OrImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/OrImpl.java?rev=1537082&r1=1537081&r2=1537082&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/OrImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/OrImpl.java
Wed Oct 30 13:37:45 2013
@@ -113,13 +113,13 @@ public class OrImpl extends ConstraintIm
             return m2;
         }
         Map<DynamicOperandImpl, Set<StaticOperandImpl>> result = Maps.newHashMap();
-        result.putAll(m1);
         for (Entry<DynamicOperandImpl, Set<StaticOperandImpl>> e2 : m2.entrySet())
{
             Set<StaticOperandImpl> l2 = e2.getValue();
             Set<StaticOperandImpl> l1 = m1.get(e2.getKey());
-            // l1 might be null (l2 not, as it's from the iterator)
-            Set<StaticOperandImpl> list = l1 == null ? l2 : Sets.union(l1, l2);
-            result.put(e2.getKey(), list);
+            if (l1 != null && !l1.isEmpty() && !l2.isEmpty()) {
+                Set<StaticOperandImpl> list = Sets.union(l1, l2);
+                result.put(e2.getKey(), list);
+            }
         }
         return result;
     }    

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=1537082&r1=1537081&r2=1537082&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
Wed Oct 30 13:37:45 2013
@@ -372,7 +372,7 @@ public class QueryTest extends AbstractR
     }
 
     @Test
-    public void testOak1096() throws RepositoryException, InterruptedException {
+    public void testOak1096() throws RepositoryException {
         Session writer = createAdminSession();
         Session reader = createAdminSession();
         try {
@@ -394,4 +394,23 @@ public class QueryTest extends AbstractR
             }
         }
     }
+    
+    @Test
+    public void testOak1128() throws RepositoryException {
+        Session session = createAdminSession();
+        Node p = session.getRootNode().addNode("etc");
+        p.addNode("p1");
+        Node r = p.addNode("p2").addNode("r", "nt:unstructured");
+        r.setProperty("nt:resourceType", "test");
+        session.save();
+        Query q = session.getWorkspace().getQueryManager().createQuery(
+                "/jcr:root/etc//*["+
+                        "(@jcr:primaryType = 'a'  or @jcr:primaryType = 'b') "+
+                        "or @nt:resourceType = 'test']", "xpath");
+        QueryResult qr = q.execute();
+        NodeIterator ni = qr.getNodes();
+        Node n = ni.nextNode();
+        assertEquals("/etc/p2/r", n.getPath());
+    }
+    
 }



Mime
View raw message