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

SQL generated from xpath with 3 or more ORed paths along with order by clause throws parseException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.6.0
    • 1.6.2, 1.8.0
    • query
    • None

    Description

      With OAK-4265, we now have ability to have ORed xpath statement. Following xpath:

      (/jcr:root/a//* | /jcr:root/b//* | /jcr:root/c//*) order by @jcr:score
      

      gets transformed as

      select [jcr:path], [jcr:score], *
      from [nt:base] as a
      where isdescendantnode(a, '/a')
      /* xpath: /jcr:root/a//* 
      order by @jcr:score */
      union select [jcr:path], [jcr:score], *
      from [nt:base] as a
      where isdescendantnode(a, '/b')
      /* xpath: /jcr:root/b//* 
      order by @jcr:score */
      order by [jcr:score]
      union select [jcr:path], [jcr:score], *
      from [nt:base] as a
      where isdescendantnode(a, '/c')
      /* xpath: /jcr:root/c//*
      order by @jcr:score */
      order by [jcr:score]
      

      That SQL, although throws parse exception:

      java.text.ParseException: Query: select [jcr:path], [jcr:score], *
      from [nt:base] as a
      where isdescendantnode(a, '/a')
      /* xpath: /jcr:root/a//* 
      order by @jcr:score */
      union select [jcr:path], [jcr:score], *
      from [nt:base] as a
      where isdescendantnode(a, '/b')
      /* xpath: /jcr:root/b//* 
      order by @jcr:score */
      order by [jcr:score]
      union(*)select [jcr:path], [jcr:score], *
      from [nt:base] as a
      where isdescendantnode(a, '/c')
      /* xpath: /jcr:root/c//*
      order by @jcr:score */
      order by [jcr:score]; expected: <end>
      

      A test statement that fails (to be put in XPathTest):

              verify("(/jcr:root/a//* | /jcr:root/b//* | /jcr:root/c//*) order by @jcr:score",
                      "select [jcr:path], [jcr:score], *\n" +
                              "from [nt:base] as a\n" +
                              "where isdescendantnode(a, '/a')\n" +
                              "/* xpath: /jcr:root/a//* \n" +
                              "order by @jcr:score */\n" +
                              "union select [jcr:path], [jcr:score], *\n" +
                              "from [nt:base] as a\n" +
                              "where isdescendantnode(a, '/b')\n" +
                              "/* xpath: /jcr:root/b//* \n" +
                              "order by @jcr:score */\n" +
                              "order by [jcr:score]\n" +
                              "union select [jcr:path], [jcr:score], *\n" +
                              "from [nt:base] as a\n" +
                              "where isdescendantnode(a, '/c')\n" +
                              "/* xpath: /jcr:root/c//*\n" +
                              "order by @jcr:score */\n" +
                              "order by [jcr:score]");
      

      Attachments

        Issue Links

          Activity

            People

              thomasm Thomas Mueller
              catholicon Vikas Saurabh
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: