SequelizeDatabaseError missing FROM-clause entry for table
This take me half day on the simple task like:
A LEFT JOIN B
Filter combined table
TLDR;
duplicating: false
Sequelize use subquery by default and sometimes doesn’t translate well.
Use duplicating duplicating: false
to convert sub-query to simple join
References
https://sequelize.org/master/class/lib/model.js~Model.html#static-method-findAll
Documentation for duplicating
is hidden here:
Mark the include as duplicating, will prevent a subquery from being used
Full Discussion
Check out this issues for the full discussion and finally answered by the author of Sequelize.
Cheers !