sequelize/sequelize — pull request #1561 by alum (2014-03-27 22:41:37+00:00)
Title: Feature/fix count with included relation

Hi,

this is a "proof of concept" PR relating to issue https://github.com/sequelize/sequelize/issues/1517
I don't expect you to merge it.

The relevant thing I wanted to show is that we need to exlude eagerly loaded relations ("includes") when doing counts unless the relations has a where clause. A real solution should recursively go through nested eagerly loaded relations and exclude the chains that do not have where clauses. However, I'm not sure where in the code this fits in so I decided to start the conversation around this POC PR. :)

I do believe that the updated test case is relevant, you might want to merge that part. There's only one Election in the test, so the count should reflect that.