sequelize/sequelize — pull request #1365 by overlookmotel (2014-02-09 12:54:40+00:00)
Title: Order by associations refactor

Code for ordering by associations refactored to use getAssociation and be less ugly - improving on PR https://github.com/sequelize/sequelize/pull/1299 which was already merged.

Required changing getAssociation to find associations by alias if provided. This will change behaviour where user code is using getAssociation to find an aliased association, but internally does not break anything.

I feel this change is for the best anyway. Previous behaviour was if Table1 was associated to Table2 with several aliases (and perhaps once with no alias), getAssociation would return the first association it found (aliased or not) and therefore could be unpredictable.

getAssociationByAlias is no longer used anywhere in Sequelize's internal code, but I've left it in case user code is utilizing it.

All MySQL tests pass.