Wrong sql request generated using include, with a basic association example (only with Jest !) #17167
-
I have a problem with sequelize V6 and a very basic example of one-to-many association. My associations :
What is working :
What is not working--> I cannot retrieve one user and his couple with an eager fetch, i.e one request.
The sql request is generated with the wrong JOIN clause, strictly the opposite of what I expect. Instead of having :
We have :
However, my example seems to fit the doc perfectly : doc-eagerLoading-V6 What am I doing wrong here ? Thank you for your help. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
A long time to find out that the problem was only occurring in the jest tests. And the responsible is here : -> If you encounter a similar issue with a weird behaviour of sequelize with jest, just do not reset the modules, or find an alternative method to reset only what you want. Why ?I do not know. It could be a bug, or perhaps not. Maybe someone reading this will have the answer. In my opinion, it is a bug. Because everything works fine (eager fetch one -> many with hasMany, associations, BelongsToGetAssociation, etc.), but not the eager fetch many -> one (belongsTo). |
Beta Was this translation helpful? Give feedback.
A long time to find out that the problem was only occurring in the jest tests.
And the responsible is here :
jest.resetModules();
-> If you encounter a similar issue with a weird behaviour of sequelize with jest, just do not reset the modules, or find an alternative method to reset only what you want.
Why ?
I do not know. It could be a bug, or perhaps not. Maybe someone reading this will have the answer.
In my opinion, it is a bug. Because everything works fine (eager fetch one -> many with hasMany, associations, BelongsToGetAssociation, etc.), but not the eager fetch many -> one (belongsTo).