-
Notifications
You must be signed in to change notification settings - Fork 19
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
broken query on using aggregate function #53
Comments
Same problem! |
I don't understand why the query is broken, but i think it's trying to impose limit/offset to the main table before joining with other table from what I see, there are several things to consider:
we expect that the count would be 2 rows, but the query behind it actually returns 2*(2 child)=4 rows. This complicates the logic for limit-offset as well because we expect it to limit only the main table but it will impose limit to the children as well (for example if we have 3*5=15 rows and we impose 7 row limit, the 1st object will have 5 children, and 2nd object will have 2 children and 3 missing)
As for handling the limit/offset, i am still at a loss of how to better tackle it |
Hi, after considering manual options, somehow i managed to make it work. Please check the manual aproach below, see if it's helpful in fixing the issue.
|
you still have this problem ? |
Basically I need the pagination to still work just like when using .findAll
However the query behaved erratically when using .paginate instead (The joins are moved over subquery, ordering options duplicated, as well as the grouping getting out of scope.
with the .paginate commented, The query defined below works okay:
The query produced using paginate:
The query produced using .findAll:
The models are defined below:
models.zip
Relationships are defined in this file:
index.zip
The text was updated successfully, but these errors were encountered: