findAll returns nothing while generated MySQL returns multiple.
See original GitHub issueThis is a very strange problem that I have been trying to hunt down for a few days now and have been all over the internet.
The following code returns no records (incorrect). If I copy and paste the raw sequelize generated MySQL and paste it into the database console, I get 20 records (correct). I would like to know what could possibly be contributing to this sort of error. If I change the where clause to a different value or different column then it works as expected. The error only happens for a few specific values with this specific column.
return models.Examination.findAll({
include:[
{
model: models.Event,
where: {
sample_id: 23
}
}
]
});
I can verify that all 20 records returned by the console do in fact have a valid sample_id of 23 so there is nothing strange going on there. As I mentioned earlier, the raw sequelize output works fine, but the value returned by ‘findAll’ is incorrect.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (2 by maintainers)
Hello. We are experimenting the same issue. Disabling sync() does not solve it. Any clue of what else it could be?
To solve this issue I moved one of the included models with a “where” clause at the bottom of the array.
Personally, I have two includes that have a where clause, yet only one of them was causing this issue. Another thing I would like to point out is if you use the “raw” option it also fixes this issue.