feathers-knex icon indicating copy to clipboard operation
feathers-knex copied to clipboard

Unable to get correct total on query with GROUP BY

Open Hendribcg opened this issue 7 years ago • 3 comments

Create a custom query with GROUP BY clause, it will return false number as total As the current SQL query to get the total number of row is by using a count statement in SQL select, if we are using GROUP BY in our SQL it will return the count in the grouped rows instead of total row count. My workaround solution is by extending the _find function and adding _clearGrouping('group'); in the query for getting count numbers.

Expected behavior

Return count of total row not the count of grouped row.

Actual behavior

It return count of grouped row.

System configuration

Tell us about the applicable parts of your setup.

Module versions (especially the part that's not working): feathers-knex 5.0.4, knex 0.16.3

Hendribcg avatar Feb 06 '19 03:02 Hendribcg

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Apologies if the issue could not be resolved. FeathersJS ecosystem modules are community maintained so there may be a chance that there isn't anybody available to address the issue at the moment. For other ways to get help see here.

stale[bot] avatar May 01 '19 03:05 stale[bot]

@daffl Are there any plans on fixing this bug anytime soon? If not, are you okay with me making a pull request to fix this? It would be nice to not have to override this service in order to get the correct total. I feel like this should be a fairly easy fix too (I think it's just a matter of adding a clearGroup call when initializing the countQuery variable).

smparsons avatar Jul 30 '20 13:07 smparsons

A pull request with a test and fix is always welcome.

daffl avatar Jul 30 '20 14:07 daffl