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

Unable to get correct total on query with GROUP BY #192

Open
Hendribcg opened this issue Feb 6, 2019 · 3 comments
Open

Unable to get correct total on query with GROUP BY #192

Hendribcg opened this issue Feb 6, 2019 · 3 comments
Labels

Comments

@Hendribcg
Copy link

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

@stale
Copy link

stale bot commented May 1, 2019

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.

@smparsons
Copy link

@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).

@daffl
Copy link
Member

daffl commented Jul 30, 2020

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

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

No branches or pull requests

3 participants