if hasmany relation result is null it gives error if it has too hasmany relationship with count function #11239
Labels
status: awaiting response
For issues and PRs. OP must respond (or change something, if it is a PR). Maintainers have no action
type: bug
What are you doing?
I have post model which hasmany reply model then reply hasmany replylike model.
To Reproduce
if I comment this line [sequelize.fn('COUNT', sequelize.col('replyLike.id')), 'replyCount'] it start working because this post has no reply yet so reply object is null and it gives "Cannot read property 'push' of undefined"
What do you expect to happen?
It should return reply object as [] empty array as it return when I comment count line!
What is actually happening?
It give me error because post has no reply so reply object is null and replyLike object is trying to push into reply object!
Output, either JSON or SQL
{
"status": "ERROR",
"statusCode": 100,
"statusMessage": "Cannot read property 'push' of undefined",
"httpCode": 500
}
The text was updated successfully, but these errors were encountered: