Retrieving all data from a junction table without specifying it on the model query #16655
Open
2 tasks done
Labels
pending-approval
Bug reports that have not been verified yet, or feature requests that have not been accepted yet
type: bug
Issue Creation Checklist
Bug Description
The problem is related to the way sequelize tries to retrieve data from a table related to other table through a junction table, but retrieves also all the data from the junction table itself. Specifying this to the case i noticed this, i'm trying to get data from a table "modalities" that is related to "courses" through a join table (one created by myself using sequelize migrations as well as all the others on my db) "course_modalities". Here is my sequelize model query and my models Course, Modality, CourseModality:
Sequelize model query:
Course Model:
Modality model:
CourseModality model
But by testing on routes, the result that i get is quite weird: i'm getting the attributes i want from "Modality" but not just that, i'm getting all the attributes from the junction table (even duplicates on camelCase, even if on my db the attributes are defined in snake_case) without specifying nothing about it. Example of one retrieved data:
The output i'm trying to get:
I'm using Sequelize v6 with MYSQL as dialect.
Indicate your interest in the resolution of this issue by adding the 👍 reaction. Comments such as "+1" will be removed.
The text was updated successfully, but these errors were encountered: