diff options
-rw-r--r-- | activerecord/lib/active_record/relation/spawn_methods.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb index 7131aa29b6..706b0cd1cc 100644 --- a/activerecord/lib/active_record/relation/spawn_methods.rb +++ b/activerecord/lib/active_record/relation/spawn_methods.rb @@ -24,7 +24,10 @@ module ActiveRecord (Relation::MULTI_VALUE_METHODS - [:joins, :where, :order]).each do |method| value = r.send(:"#{method}_values") - merged_relation.send(:"#{method}_values=", merged_relation.send(:"#{method}_values") + value) if value.present? + next if value.empty? + + value += merged_relation.send(:"#{method}_values") + merged_relation.send :"#{method}_values=", value end merged_relation.joins_values += r.joins_values |