sequelize/sequelize — pull request #1095 by lemon-tree (2013-11-28 19:48:59+00:00)
Title: Prevention of duplicate records on multiple include hasMany joins

This is a fix for #976, where using more than one hasMany include on a single fetch could result in duplication of records in the results due to the output format of the rows.

All that has changed is that we now examine any subsequent rows to check we aren't adding information we already have. This is based on the assumption that no two records will have the exact same data, which is reasonable given that each should have its own unique primary key.

Looks like it could also fix #335 as the issue appears identical, with a very similar solution actually being posted in those comments over a year ago.