You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Nitin Gupta (Jira)" <ji...@apache.org> on 2020/01/18 11:44:00 UTC
[jira] [Created] (OAK-8866) coalesce function does not works
Nitin Gupta created OAK-8866:
--------------------------------
Summary: coalesce function does not works
Key: OAK-8866
URL: https://issues.apache.org/jira/browse/OAK-8866
Project: Jackrabbit Oak
Issue Type: Bug
Reporter: Nitin Gupta
Create and index definition with coalesce([foo2],[foo])
Expected behavior - query with filter condition such as "where coalesce([foo2],[foo]) ='XYZ' " should work - but it doesn't.
coalesce([foo2],[foo]) seems to return the result for [foo2] only and in case [foo2] is null - then it returns [foo] - but doesn't return the expected value of [foo2]+[foo]
Test Case to reproduce ->
{code:java}
public class FunctionIndexTest extends AbstractQueryTest {
.
.
.
@Test
public void testCoalesce() throws Exception {
IndexDefinitionBuilder idxb = new IndexDefinitionBuilder().noAsync();
idxb.indexRule("nt:base").property("foo", null).function(
"coalesce([foo2], [foo])"
).ordered();
Tree idx = root.getTree("/").getChild("oak:index").addChild("test1");
idxb.build(idx);
root.commit();
Tree rootTree = root.getTree("/");
Tree n1 = rootTree.addChild("a");
n1.setProperty("foo2", "hello");
n1.setProperty("foo","world");
n1 = rootTree.addChild("b");
n1.setProperty("foo2", "aaaa");
n1.setProperty("foo","bbbb");
n1 = rootTree.addChild("c");
n1.setProperty("foo2", "test");
n1.setProperty("foo","test");
n1 = rootTree.addChild("d");
n1.setProperty("foo2", "helloworld");
n1.setProperty("foo","test");
root.commit();
String query = "select [jcr:path] from [nt:base] where coalesce([foo2],[foo]) = 'helloworld'";
List<String> result = executeQuery(query, SQL2);
// This should give /a in result
// but instead it gives /d and fails
assertEquals(asList("/a"), result);
}
.
.
.
}
{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)