-
Bug
-
Resolution: Done
-
Major
-
4.3.0.Final
-
None
Given a node with a multi-value property, the following query never returns any result.
SELECT * FROM [scheme:type] AS t WHERE LOWER(t.multiValue) = 'lowercase'
Query returns results as soon as LOWER operand is removed.
Example code
class Runner { public static void main(String[] args) throws Exception { Session session = getSession(); prepareRepository(session); createNode(new MyValueObject("1", new String[] {"A", "B"}), session); createNode(new MyValueObject("2", new String[] {"C", "b"}), session); session.save(); session.logout(); Session session2 = getSession(); javax.jcr.query.Query query = session2.getWorkspace().getQueryManager().createQuery("select * from [namespace:mymixin] as m WHERE LOWER(m.titles) = 'b'", javax.jcr.query.Query.JCR_SQL2); QueryResult queryResult = query.execute(); assert queryResult.getRows().getSize() == 2; session2.logout(); } static private void prepareRepository(Session session) throws RepositoryException { session.getWorkspace().getNamespaceRegistry().registerNamespace("namespace", "http://blah.com/blah/blah"); NodeTypeManager manager= session.getWorkspace().getNodeTypeManager(); NodeTypeTemplate template = manager.createNodeTypeTemplate(); template.setName("namespace:mymixin"); template.setQueryable(true); template.setAbstract(false); template.setMixin(true); manager.registerNodeType(template, false); } static private Node createNode(MyValueObject vo, Session session) throws RepositoryException { final Node node; node = session.getRootNode().addNode(vo.getId()); node.addMixin("namespace:mymixin"); node.setProperty("titles", vo.getTitles()); return node; } private static Session getSession() //Create new JCR Session static class MyValueObject { private final String id; private final String[] titles; public MyValueObject(String id, String[] titles) { this.id = id; this.titles = titles; } public String getId() { return id; } public String[] getTitles() { return titles; } } }