Pager is not shown for pages having attached UNION to them

Created on 15 May 2024, 6 months ago
Updated 12 June 2024, 5 months ago

Problem/Motivation

Views that have attached an Union display to them do not show the pager.

Steps to reproduce

Install module, create a new view, attach an union display to that view.

Proposed resolution

The issue is that the pager count the number of items using

SELECT count(*) as "expression" from (
SELECT 1 AS EXPRESSION ...
UNION
SELECT 1 AS EXPRESSION ...
) subquery;

which always returns 1.

By using UNION ALL the rows would be different and the count would not be all the time.

I am sure that there is a reason UNION ALL was not used from the beginning but I am not sure what that reason was.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @leontin
    • cac34fe9 committed on 1.0.x
      Issue #3447393: Pager is not shown for pages having attached UNION to...
  • πŸ‡ΊπŸ‡ΈUnited States gribnif

    The problem with using UNION ALL is that it creates new rows for every row that each subquery has in common. So if the main query returns entity IDs (1,2,3,4) and the first UNION returns (2,3,5), the result set will be (1,2,3,4,2,3,5). While there might be a rare case where this is the desired result, it would break backward compatibility.

    Instead, I have added a dummy HAVING clause so that the built-in query constructor won't try to remove the entity ID field from the UNION query. This fixes pagination.

    I could see the argument for relying on the Distinct option in Query Settings to determine which behavior is used. But I wouldn't want to do this in a minor version because of the BC problem.

  • Status changed to Fixed 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States gribnif
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024