aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
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/test
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/test')
-rw-r--r--activerecord/test/cases/relation/merging_test.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/relation/merging_test.rb b/activerecord/test/cases/relation/merging_test.rb
index 0a2e874e4f..60a806c05a 100644
--- a/activerecord/test/cases/relation/merging_test.rb
+++ b/activerecord/test/cases/relation/merging_test.rb
@@ -104,6 +104,13 @@ class RelationMergingTest < ActiveRecord::TestCase
post = PostThatLoadsCommentsInAnAfterSaveHook.create!(title: "First Post", body: "Blah blah blah.")
assert_equal "First comment!", post.comments.where(body: "First comment!").first_or_create.body
end
+
+ def test_merging_with_from_clause
+ relation = Post.all
+ assert relation.from_clause.empty?
+ relation = relation.merge(Post.from("posts"))
+ refute relation.from_clause.empty?
+ end
end
class MergingDifferentRelationsTest < ActiveRecord::TestCase