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

Use getCountForPagination for query count #298

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Jade-GG
Copy link

@Jade-GG Jade-GG commented Feb 13, 2025

The count query doesn't always work properly under certain conditions, specifically a query with a GROUP BY seems to be the issue.

We can use the getCountForPagination function that laravel provides and uses internally for the pagination function. Scout itself actually also uses this function to get the count.

@matchish
Copy link
Owner

I would be cool if you add a test that fails without using getCountForPagination and pass with

@Jade-GG
Copy link
Author

Jade-GG commented Feb 14, 2025

I would be cool if you add a test that fails without using getCountForPagination and pass with

I did try for a bit but couldn't really get it to work unfortunately (and I'd rather not spend too much time on tinkering with the tests at this moment). I will also say that I can't find the exact cause of the incorrect count we encountered---it has something to do with combining joins an group by and possibly also global scopes... it's a mess.

Don't know if it's really that necessary to have a test for this at the end of the day 🙂

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

Successfully merging this pull request may close these issues.

2 participants