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

Make query.count() also work for any column

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 12.4
    • Fix Version/s: None
    • Component/s: Query
    • Labels:
      None
    • Difficulty:
      Unknown
    • Similar issues:

      Description

      If you don't specify the select part,

       select doc.fullname from Document doc 

      is concatenated to the passed query.

      The problem is when you are adding a different select at the beginning of the query, that doesn't contain 'doc.fullname' column, since this will make the count filter to not work and simply return -1

      Here is an example that selects only attachments filename from a document and where $query.count() returns -1

      #set ($query = $services.query.hql("select attachment.filename from XWikiAttachment attachment, XWikiDocument doc where doc.id = attachment.docId and doc.id = :docId order by lower(attachment.filename) asc, attachment.filename asc"))
      #set ($discard = $query.bindValue('docId', $doc.getId()))
      #set ($attachments = $query.execute())
      $query.count()
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              oana.florean@xwiki.com Florean Oana-Lavinia
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Date of First Response: