Skip to content

Commit

Permalink
Fix bug in hasMany.set when models have custom primary keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Scheurer committed Jun 27, 2014
1 parent 85ee802 commit 9e804c2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/associations/has-many-double-linked.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ module.exports = (function() {

unassociatedObjects = newAssociations.filter(function(obj) {
return !Utils._.find(oldAssociations, function(old) {
return (!!obj[foreignIdentifier] && !!old[foreignIdentifier] ? obj[foreignIdentifier] === old[foreignIdentifier] : obj.id === old.id);
return (!!obj[foreignIdentifier] ? obj[foreignIdentifier] === old[foreignIdentifier] : (!!obj[targetKeys[0]] ? obj[targetKeys[0]] === old[targetKeys[0]] : obj.id === old.id));
});
});

oldAssociations.forEach(function(old) {
var newObj = Utils._.find(newAssociations, function(obj) {
return (!!obj[foreignIdentifier] && !!old[foreignIdentifier] ? obj[foreignIdentifier] === old[foreignIdentifier] : obj.id === old.id);
return (!!obj[foreignIdentifier] ? obj[foreignIdentifier] === old[foreignIdentifier] : (!!obj[targetKeys[0]] ? obj[targetKeys[0]] === old[targetKeys[0]] : obj.id === old.id));
});

if (!newObj) {
Expand Down

0 comments on commit 9e804c2

Please sign in to comment.