sequelize/sequelize — pull request #834 by lemon-tree (2013-08-14 22:39:38+00:00)
Title: Eager loading of many-many associations

These commits add support for eager loading of many-many associations through a junctionTable on all three dialects, which is achieved by performing the expected two joins. See the new test code for an example, it's essentially the same as any other include.

It doesn't have support for non-standard named primary keys, but that should be possible with a couple of tweaks. There's also probably some cleaning up to be done, but that can be sorted before merging and once some others have confirmed it is a viable solution.

Also, this fixes a bug whereby only one many-many association direction had the foreignIdentifier property defined properly. Now both directions have the correct properties.