aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/merger.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2016-01-14 13:35:48 -0700
committerSean Griffin <sean@seantheprogrammer.com>2016-01-14 13:36:30 -0700
commitf138bea5da463509c0dc51283dd35e803796a77a (patch)
tree81392a41912fd35f5aebe9290fc504f4afd68ee8 /activerecord/lib/active_record/relation/merger.rb
parentb7cce1c0a92ef88341137290eefd19ef688c175b (diff)
downloadrails-f138bea5da463509c0dc51283dd35e803796a77a.tar.gz
rails-f138bea5da463509c0dc51283dd35e803796a77a.tar.bz2
rails-f138bea5da463509c0dc51283dd35e803796a77a.zip
Properly include the `from` clause when merging relations
The code that set the from clause was removed in bdc5141652770fd227455681cde1f9899f55b0b9. I did not give any reason for doing so. My assumption was that I intended to change it to use the clause objects, but forgot. We appeared to not have test coverage for this case. Fixes #22996
Diffstat (limited to 'activerecord/lib/active_record/relation/merger.rb')
-rw-r--r--activerecord/lib/active_record/relation/merger.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation/merger.rb b/activerecord/lib/active_record/relation/merger.rb
index cb971eb255..396638d74d 100644
--- a/activerecord/lib/active_record/relation/merger.rb
+++ b/activerecord/lib/active_record/relation/merger.rb
@@ -141,6 +141,9 @@ module ActiveRecord
end
def merge_single_values
+ if relation.from_clause.empty?
+ relation.from_clause = other.from_clause
+ end
relation.lock_value ||= other.lock_value
unless other.create_with_value.blank?