此问题已在Sequelize 3.0.1中修复,必须使用以下命令排除包含模型的主键:
attributes: []
并且必须在主模型上完成聚合(此github问题中的信息)。
因此,对于我的用例,代码如下
models.contracts.findAll({ attributes: ['id', [models.sequelize.fn('sum', models.sequelize.col('payments.payment_amount')), 'total_cost']], include: [ { model: models.payments, attributes: [] } ], group: ['contracts.id']})


