Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-15015

Fix pagination in Microsoft SQL Server for queries using UNION


    • Branch Version/s:
      6.0.x, 5.2.x
    • Backported to Branch:


      As a result of LPS-9903, pagination does not work if the ORDER BY uses column aliases.

      While LPS-14537 fixed that issue, it introduced a separate defect where pagination failed if the query had a union, because it added the "row_number()" column to the first part, but not on the subsequent parts that were being unioned together.

      The solution isn't as straightforward as adding a row_number() to every subquery being unioned, because the resulting row numbers will not match the row numbers we actually want, since what we actually want is the row_number() according to the order by on the unioned result.

      Therefore, the natural solution in this case is to do another level of nesting – to re-select the columns and the row number of the unioned result. Though this will result in a reduction in performance, it should still be better than no pagination.


          Issue Links



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


                • Created:
                  Days since last comment:
                  9 years, 18 weeks, 4 days ago


                  Version Package
                  --Sprint - SP
                  6.0.6 GA
                  6.1.0 CE RC1