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

Commit a358e467 by Mick Hansen

only delete inferred otherKey if different

1 parent 04c3feb1
Showing with 7 additions and 5 deletions
......@@ -158,21 +158,23 @@ module.exports = (function() {
}
}
if (this.through) {
this.throughModel = this.through.model;
}
if (this.paired) {
if (this.otherKeyDefault) {
this.otherKey = this.paired.foreignKey;
}
if (this.paired.otherKeyDefault) {
// If paired otherKey was inferred we should make sure to clean it up before adding a new one that matches the foreignKey
delete this.through.model.rawAttributes[this.paired.otherKey];
if (this.paired.otherKey !== this.foreignKey) {
delete this.through.model.rawAttributes[this.paired.otherKey];
}
this.paired.otherKey = this.foreignKey;
}
}
if (this.through) {
this.throughModel = this.through.model;
}
this.options.tableName = this.combinedName = (this.through.model === Object(this.through.model) ? this.through.model.tableName : this.through.model);
if (this.as) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!