You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
findAll returns wrong number of instances when using LIMIT and filtered many-to-many association #5715
When using LIMIT and a filtered many-to-many association, findAll returns the wrong number of instances. In my case, it was always one less than expected.
I've written a simple app to check if I can reproduce the behaviour, which I copied to this gist. (Sorry it's not a proper test.) This code should return two items, but it returns only one.
The include.where statement is not used in the subquery filter on the include. So the subquery will return two rows but they won't all have the correct categories.name and then be filtered further.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂
I am confused, is this still an issue with the latest Sequelize? If yes, can someone please post an SSCCE (also known as MCVE/reprex)? Once it's done I will reopen this.
Activity
janmeier commentedon Apr 7, 2016
What does the sql look like?
VividVisions commentedon Apr 7, 2016
This is the generated SQL:
mickhansen commentedon Apr 8, 2016
The include.where statement is not used in the subquery filter on the include. So the subquery will return two rows but they won't all have the correct categories.name and then be filtered further.
Djalmar commentedon Apr 11, 2016
Same problem here, any workaround ?
davidninam commentedon Apr 12, 2016
Any news, about this problem?
Alexsey commentedon Jun 9, 2017
My issue #7344 is looks like the same. #4716 is also looks like the same and there is a workaround - add
subQuery: falsestale commentedon Aug 12, 2017
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂
Djalmar commentedon Sep 4, 2017
is still a issue
SirWojtek commentedon Jan 9, 2018
I found another workaround working for me. I've just added
distinct: trueto myfindAndCountAllquery.mllumiquinga194 commentedon Aug 17, 2019
subQuery: false, 16-08-2019
papb commentedon Aug 17, 2019
I am confused, is this still an issue with the latest Sequelize? If yes, can someone please post an SSCCE (also known as MCVE/reprex)? Once it's done I will reopen this.
Drilonpacarizi commentedon Nov 21, 2020