Skip to content

Commit

Permalink
APP-3029 Fixes prune duplicates. All records with a nil primary key g…
Browse files Browse the repository at this point in the history
…et their primary key replaced by a new object, which will never compare true to anything else. (localytics#28)
  • Loading branch information
ACerka-Springbuk authored Jul 24, 2023
1 parent 8ad3e62 commit ecd6964
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/active_record/merge_all.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ def do_prune_duplicates
end
@merges = merges.reverse
merges.uniq! do |merge|
primary_keys.map { |key| merge[key] }
# Map the primary keys to determine uniqueness. If a primary key is nil, return a new empty object to
# guarantee a unique value. We don't ever want to throw out records that have a nil primary key as these are
# new records.
primary_keys.map { |key| merge[key].nil? ? Object.new : merge[key] }
end
merges.reverse!
end
Expand Down

0 comments on commit ecd6964

Please sign in to comment.