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.
Limit causing “missing FROM-clause entry for table” · Issue #4446 · sequelize/sequelize
Hi, Got an issue with sequelize, tried 3.5 and 3.7.1, using postgres. I added as much detail as I could below, but the short version is that adding limit to a query with an include results in a dif…
Cheers !