jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r464466 - in /jackrabbit/trunk/jackrabbit/src: main/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java test/java/org/apache/jackrabbit/core/query/SimpleQueryTest.java
Date Mon, 16 Oct 2006 12:34:57 GMT
Author: mreutegg
Date: Mon Oct 16 05:34:56 2006
New Revision: 464466

URL: http://svn.apache.org/viewvc?view=rev&rev=464466
Log:
JCR-562: 'OR' in XPath query badly interpreted

Modified:
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/SimpleQueryTest.java

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java?view=diff&rev=464466&r1=464465&r2=464466
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/query/xpath/XPathQueryBuilder.java
Mon Oct 16 05:34:56 2006
@@ -402,17 +402,17 @@
                 break;
             case JJTOREXPR:
                 NAryQueryNode parent = (NAryQueryNode) queryNode;
-                queryNode = new OrQueryNode(parent);
-                parent.addOperand(queryNode);
+                QueryNode orQueryNode = new OrQueryNode(parent);
+                parent.addOperand(orQueryNode);
                 // traverse
-                node.childrenAccept(this, queryNode);
+                node.childrenAccept(this, orQueryNode);
                 break;
             case JJTANDEXPR:
                 parent = (NAryQueryNode) queryNode;
-                queryNode = new AndQueryNode(parent);
-                parent.addOperand(queryNode);
+                QueryNode andQueryNode = new AndQueryNode(parent);
+                parent.addOperand(andQueryNode);
                 // traverse
-                node.childrenAccept(this, queryNode);
+                node.childrenAccept(this, andQueryNode);
                 break;
             case JJTCOMPARISONEXPR:
                 createExpression(node, (NAryQueryNode) queryNode);

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/SimpleQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/SimpleQueryTest.java?view=diff&rev=464466&r1=464465&r2=464466
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/SimpleQueryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/query/SimpleQueryTest.java
Mon Oct 16 05:34:56 2006
@@ -480,4 +480,29 @@
         checkResult(result, new Node[]{foo, blu});
     }
 
+    public void testLogicalExpression() throws Exception {
+        Node foo = testRootNode.addNode("foo");
+        foo.setProperty("a", 1);
+        foo.setProperty("b", 2);
+        foo.setProperty("c", 3);
+        Node bar = testRootNode.addNode("bar");
+        bar.setProperty("a", 0);
+        bar.setProperty("b", 2);
+        bar.setProperty("c", 0);
+        Node bla = testRootNode.addNode("bla");
+        bla.setProperty("a", 1);
+        bla.setProperty("b", 0);
+        bla.setProperty("c", 3);
+        testRootNode.save();
+
+        String sql = "SELECT * FROM nt:unstructured WHERE a=1 and b=2 or c=3";
+        Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
+        QueryResult result = q.execute();
+        checkResult(result, new Node[]{foo, bla});
+
+        String xpath = "//*[@a=1 and @b=2 or @c=3] ";
+        q = superuser.getWorkspace().getQueryManager().createQuery(xpath, Query.XPATH);
+        result = q.execute();
+        checkResult(result, new Node[]{foo, bla});
+    }
 }



Mime
View raw message