Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-15595

Unique Query Filter not working on query.execute() while working on query.count()

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Critical
    • None
    • 9.7
    • Query
    • None
    • Unknown

    Description

      1. Create a class Main.TestClass with a String property a
      2. Create a document with 5 object of your class and set the value of the a property in only 2 of the objects, others leave them blank.
      3. Run the following query and observe the results:
      {{velocity}}
      #set ($limit = 10)
      #set ($offset = 0)
      #set ($sqlParams = ["Main.TestClass"])
      #set ($query = $services.query.hql(", BaseObject as obj , StringProperty prop  where obj.name=doc.fullName and obj.className = ? and obj.id=prop.id.id and prop.name = 'a'  order by prop.value asc").addFilter('unique').setLimit($limit).setOffset($offset).bindValues($sqlParams))
      query: $query
      #set ($results = $query.execute())
      execute: $results
      execute.size(): $results.size()
      count: $query.count()
      {{/velocity}}
      

      Expected Output:
      both execute() and count() should have returned 1, since the unique filter should have done its job in selecting a single distinct document.

      Actual Output:

      query: org.xwiki.query.internal.ScriptQuery@66578d32
      execute: [Main.TestObj.WebHome, Main.TestObj.WebHome, Main.TestObj.WebHome]
      execute.size(): 3
      count: 1
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              enygma Eduard Moraru
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: