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
Missing data when querying for data with associated model using separate: true #14805
When there is a many to many association between data in two tables/models and the junction table has a compound primary key there is an issue with data being lost for the associated model when using findAll with separate: true.
The ids of the junction table when appended as a string no longer form a unique id in _groupJoinData function in lib/dialects/abstract/query.js. As a result data for the associated model is dropped when grouping the results.
I would expect that when using findAll and including an associated model with separate: true the associated data will be returned for all instances that have been found. In the example provided both Tasks should have one associated TaskCountry returned as a result of the findAll query.
What is actually happening?
When _groupJoinData groups the results it considers some of them as duplicates and drops them. This results in data missing in the results of the query. In the example provided one of the associated TaskCountries has been dropped and is missing in the result of the findAll.
Environment
Sequelize version: 6.21.3
Node.js version: 14.17.6
If TypeScript related: TypeScript version: 4.5.5
Database & Version: PostgreSQL 10
Connector library & Version: 8.7.3
Would you be willing to resolve this issue by submitting a Pull Request?
No, I don't have the time, and I understand that I will need to wait until someone from the community or maintainers is interested in resolving my issue.
Indicate your interest in the resolution of this issue by adding the 👍 reaction. Comments such as "+1" will be removed.
Reacted by Radek Litman, Filip Ježek and Tolgahan Çelik
This issue has been automatically marked as stale because it has been open for 14 days without activity. It will be closed if no further activity occurs within the next 14 days. If this is still an issue, just leave a comment or remove the "stale" label. 🙂
Activity
github-actions commentedon Aug 10, 2022
This issue has been automatically marked as stale because it has been open for 14 days without activity. It will be closed if no further activity occurs within the next 14 days. If this is still an issue, just leave a comment or remove the "stale" label. 🙂
konradgaca commentedon Aug 19, 2022
Bump up as it is still an issue.
harsh-lamba commentedon Aug 23, 2022
Same with me.