From f138bea5da463509c0dc51283dd35e803796a77a Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Thu, 14 Jan 2016 13:35:48 -0700 Subject: 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 --- activerecord/lib/active_record/relation/merger.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'activerecord/lib/active_record/relation/merger.rb') 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? -- cgit v1.2.3