Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong results count in List when using GROUP BY #644

Open
Giuse69 opened this issue May 3, 2022 · 1 comment
Open

wrong results count in List when using GROUP BY #644

Giuse69 opened this issue May 3, 2022 · 1 comment

Comments

@Giuse69
Copy link
Contributor

Giuse69 commented May 3, 2022

When displaying a list of items with a List Type, if no conditions are set (no field is the Search View is filled), the plugins\search\cck\cck.orig calculates the number of results, and related results pagination, but the count is wrong when a GROUP BY condition has been added in the Search Query field and that group by is not "#__cck_core.id" .
This is due to the fact that cck.php in line 443 clears the GROUP BY conditions and repeats the select with a COUNT('DISTINCT t0.id)'): the result is wrong since the GROUP BY reduces the number of results and infact the pagination is not fully working - last pages are empty since there are less results than the query has calculated.
A possible fix is to replace
if ( $hasGroup ) { $query->clear( 'group' ); $query->select( 'COUNT(DISTINCT t0.id)' );
with
if ( $hasGroup ) { $query->select('DISTINCT COUNT(*) OVER ()');
using at least mySQL 5.7 or mariaDB 10.2 that supports windowing functions (OVER operator).

Giuse

@Giuse69
Copy link
Contributor Author

Giuse69 commented Jul 8, 2023

After 14 months can I ask for a feedback?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant