Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-2491

LOWER operand on a multi-value propetry does not match in WHERE clause

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 4.3.0.Final
    • Fix Version/s: 4.4.0.Final
    • Component/s: JCR, Query
    • Labels:
      None

      Description

      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;
              }
          }
      }
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                hchiorean Horia Chiorean
                Reporter:
                seveneves Ivan Stanislavciuc
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: