From 587f563c40cfada296d6e8d6bbe3c4d7fc6ce93b Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Mon, 11 Feb 2013 21:24:11 +0100 Subject: don't cache invalid subsets when preloading hmt associations. Backport #9252. Conflicts: activerecord/CHANGELOG.md activerecord/test/cases/associations/eager_test.rb The preloader code on 3-2-stable is not based on relations but on option hashes. I had to modify the original patch and comparing the option hashes could be more fuzzy than comparing the relations. All the tests passed though. --- activerecord/test/cases/associations/eager_test.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index 20c6b691fc..5d07ffa241 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -1112,4 +1112,10 @@ class EagerAssociationTest < ActiveRecord::TestCase Post.includes(:comments).order(nil).where(:comments => {:body => "Thank you for the welcome"}).first end end + + test "preloading does not cache has many association subset when preloaded with a through association" do + author = Author.includes(:comments_with_order_and_conditions, :posts).first + assert_no_queries { assert_equal 2, author.comments_with_order_and_conditions.size } + assert_no_queries { assert_equal 5, author.posts.size, "should not cache a subset of the association" } + end end -- cgit v1.2.3