不要怂,就是干,撸起袖子干!

Commit 07e89dc4 by Mick Hansen

fix(belongs-to-many): ambigious id when through model has id

1 parent 0778e540
...@@ -443,7 +443,7 @@ BelongsToMany.prototype.injectGetter = function(obj) { ...@@ -443,7 +443,7 @@ BelongsToMany.prototype.injectGetter = function(obj) {
options = association.target.__optClone(options) || {}; options = association.target.__optClone(options) || {};
options.attributes = [ options.attributes = [
[sequelize.fn('COUNT', sequelize.col(model.primaryKeyAttribute)), 'count'] [sequelize.fn('COUNT', sequelize.col([association.target.name, model.primaryKeyAttribute].join('.'))), 'count']
]; ];
options.joinTableAttributes = []; options.joinTableAttributes = [];
options.raw = true; options.raw = true;
......
...@@ -423,6 +423,11 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() { ...@@ -423,6 +423,11 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
active: DataTypes.BOOLEAN active: DataTypes.BOOLEAN
}); });
this.UserTask = this.sequelize.define('UserTask', { this.UserTask = this.sequelize.define('UserTask', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
started: { started: {
type: DataTypes.BOOLEAN, type: DataTypes.BOOLEAN,
defaultValue: false defaultValue: false
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!