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

Commit 818f7077 by XadillaX

fix a bug that using `Instance::destroy()` under multiple primary keys

1 parent a3155ec8
Showing with 4 additions and 1 deletions
...@@ -836,7 +836,10 @@ module.exports = (function() { ...@@ -836,7 +836,10 @@ module.exports = (function() {
return this.save(_.extend(_.clone(options), {hooks : false})); return this.save(_.extend(_.clone(options), {hooks : false}));
} else { } else {
where = {}; where = {};
where[this.Model.rawAttributes[this.Model.primaryKeyAttribute].field] = this.get(this.Model.primaryKeyAttribute, {raw: true}); var primaryKeys = this.Model.primaryKeyAttributes;
for(var i = 0; i < primaryKeys.length; i++) {
where[this.Model.rawAttributes[primaryKeys[i]].field] = this.get(primaryKeys[i], { raw: true });
}
return this.QueryInterface.delete(this, this.Model.getTableName(options), where, _.defaults(options, { type: QueryTypes.DELETE,limit: null})); return this.QueryInterface.delete(this, this.Model.getTableName(options), where, _.defaults(options, { type: QueryTypes.DELETE,limit: null}));
} }
}).tap(function() { }).tap(function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!