You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by th...@apache.org on 2015/09/18 10:54:47 UTC
svn commit: r1703776 - in /jackrabbit/oak/trunk:
oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/EquiJoinConditionImpl.java
oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java
Author: thomasm
Date: Fri Sep 18 08:54:47 2015
New Revision: 1703776
URL: http://svn.apache.org/viewvc?rev=1703776&view=rev
Log:
OAK-3416 Query: join on different property types fails
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/EquiJoinConditionImpl.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/EquiJoinConditionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/EquiJoinConditionImpl.java?rev=1703776&r1=1703775&r2=1703776&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/EquiJoinConditionImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/EquiJoinConditionImpl.java Fri Sep 18 08:54:47 2015
@@ -62,16 +62,30 @@ public class EquiJoinConditionImpl exten
@Override
public boolean evaluate() {
+ // 6.7.8 EquiJoinCondition
+ // A node-tuple satisfies the constraint only if:
PropertyValue p1 = selector1.currentProperty(property1Name);
if (p1 == null) {
+ // the selector1Name node has a property named property1Name, and
return false;
}
PropertyValue p2 = selector2.currentProperty(property2Name);
if (p2 == null) {
+ // the selector2Name node has a property named property2Name, and
return false;
}
+ // the value of property property1Name is equal to the value of property property2Name,
+ // as defined in §3.6.5 Comparison of Values.
+ // -> that can be interpreted as follows: if the property types
+ // don't match, then they don't match, however for compatibility
+ // with Jackrabbit 2.x, we try to convert the values so the property types match
+ // (for example, convert reference to string)
+ // See OAK-3416
if (!p1.isArray() && !p2.isArray()) {
// both are single valued
+ // "the value of operand2 is converted to the
+ // property type of the value of operand1"
+ p2 = convertValueToType(p2, p1);
return PropertyValues.match(p1, p2);
}
// TODO what is the expected result of an equi join for multi-valued properties?
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=1703776&r1=1703775&r2=1703776&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 Fri Sep 18 08:54:47 2015
@@ -69,7 +69,6 @@ public class QueryTest extends AbstractR
}
@Test
- @Ignore("OAK-3416")
public void join() throws Exception {
Session session = getAdminSession();
Node root = session.getRootNode();
@@ -85,6 +84,12 @@ public class QueryTest extends AbstractR
"inner join [nt:unstructured] as [b] " +
"on [a].[jcr:uuid] = [b].[join] where issamenode([a], '/a')",
Query.JCR_SQL2));
+ assertEquals("/a",
+ getNodeList(session,
+ "select [a].* from [nt:unstructured] as [a] "+
+ "inner join [nt:unstructured] as [b] " +
+ "on [b].[join] = [a].[jcr:uuid] where issamenode([a], '/a')",
+ Query.JCR_SQL2));
}
@Test