Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-23395

Fix totalSize computation in Query SELECTing from lists

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 8.10, 9.3-SNAPSHOT
    • Fix Version/s: 9.10
    • Component/s: Core, Query & PageProvider

      Description

      When executing a query like

      SELECT dc:subjects/* FROM File WHERE ecm:name = 'doc1'
      

      returns a total size of 1 even if result set is empty.

      Easy reproduction use case

      • create a Collection
      • send a GET request on the Rest API
        http://localhost:5000/nuxeo/api/v1/search/pp/ordered_content_collection/execute?offset=0&pageSize=40&queryParams={collectionUuid}
        
      • observe the response
        {"entity-type":"documents","isPaginable":true,"resultsCount":1,"pageSize":43,"maxPageSize":1000,"resultsCountLimit":43,"currentPageSize":0,"currentPageIndex":0,"currentPageOffset":0,"numberOfPages":1,"isPreviousPageAvailable":false,"isNextPageAvailable":false,"isLastPageAvailable":false,"isSortable":true,"hasError":false,"errorMessage":null,"totalSize":1,"pageIndex":0,"pageCount":1,"entries":[]}
        

        saying "resultsCount":1 but with empty entries.

      Reason
      Probably caused by the LEFT JOIN between subject id and hierarchy id in the tranlasted query:

      SELECT DC_SUBJECTS.ITEM
      FROM HIERARCHY
      LEFT JOIN DC_SUBJECTS ON HIERARCHY.ID = DC_SUBJECTS.ID 
      LEFT JOIN DUBLINCORE ON HIERARCHY.ID = DUBLINCORE.ID
      WHERE HIERARCHY.PRIMARYTYPE IN (?, ?) AND HIERARCHY.NAME = ?
      ORDER BY DUBLINCORE.TITLE, HIERARCHY.ID, DC_SUBJECTS.POS
      

      Unit test

          @Test
          public void testQueryIdListNotFromUuidTotalSize() throws Exception {
              // We need at least such a doc which will make the left join return a null
              DocumentModel doc1 = new DocumentModelImpl("/", "doc1", "File");
              doc1 = session.createDocument(doc1);
              doc1 = session.saveDocument(doc1);
              session.save();
              DocumentModelList dml;
              String query = "SELECT dc:subjects/* FROM File WHERE ecm:name = 'doc1'";
              dml = session.query(query, null, 10, 0, true);
              assertEquals(0, dml.totalSize());
          }
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 3 days
                  3d