Uploaded image for project: 'Jackrabbit Oak'
  1. Jackrabbit Oak
  2. OAK-9252

Query: multi-valued property condition can fail with "Type must be an array type"

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.36.0
    • None
    • None

    Description

      A condition of the form "property = 'literal'" can fail with the error messageĀ "Type must be an array type" if:

      • the property is multi-value and has no entries (count 0)
      • the property type is not String (e.g. Name)

      Example query:

      select * from [nt:base]
      where isdescendantnode('/etc') 
      and [jcr:mixinTypes] = 'mix:referenceable' 
      

      This can fail if there is no index for this (e.g. by disabling the nodetype index), and if there is a node with an empty mixin type. Test case (org.apache.jackrabbit.oak.jcr.query.QueryTest):

          @Test
          public void emptyMixin() throws RepositoryException {
              Session session = createAdminSession();
              Node p = session.getRootNode().addNode("etc");
              Node r = p.addNode("r", "nt:unstructured");
              r.addMixin("mix:referenceable");
              session.save();
              r.removeMixin("mix:referenceable");
              session.save();
              assertTrue(r.hasProperty("jcr:mixinTypes"));
              Property mix = r.getProperty("jcr:mixinTypes");
              assertTrue(mix.isMultiple());
              assertEquals(0, mix.getValues().length);
              session.save();
              Query q = session.getWorkspace().getQueryManager().createQuery(
                      "select * from [nt:base] where isdescendantnode('/etc') " +
                      "and [jcr:mixinTypes] = 'mix:referenceable' " +
                      "option(index name [x])", Query.JCR_SQL2);
              QueryResult qr = q.execute();
              NodeIterator ni = qr.getNodes();
              assertFalse(ni.hasNext());
              session.logout();
          }
      

      Attachments

        Activity

          People

            thomasm Thomas Mueller
            thomasm Thomas Mueller
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: