Skip to content

Commit

Permalink
Merge pull request #9870 from senny/9806_eager_loading_regression
Browse files Browse the repository at this point in the history
do not reset associations when preloading twice.
  • Loading branch information
jonleighton committed Mar 22, 2013
2 parents 69599b6 + c8edd4f commit ae2baab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Expand Up @@ -56,8 +56,7 @@ def through_options
through_options[:include] = options[:include] || options[:source] through_options[:include] = options[:include] || options[:source]
through_options[:conditions] = options[:conditions] through_options[:conditions] = options[:conditions]
end end

through_options[:order] = options[:order] if options.has_key?(:order)
through_options[:order] = options[:order]
end end


through_options through_options
Expand Down
7 changes: 7 additions & 0 deletions activerecord/test/cases/associations/eager_test.rb
Expand Up @@ -1118,4 +1118,11 @@ def test_join_eager_with_nil_order_should_generate_valid_sql
assert_no_queries { assert_equal 2, author.comments_with_order_and_conditions.size } 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" } assert_no_queries { assert_equal 5, author.posts.size, "should not cache a subset of the association" }
end end

test "preloading a through association twice does not reset it" do
members = Member.includes(current_membership: :club).includes(:club).to_a
assert_no_queries {
assert_equal 3, members.map(&:current_membership).map(&:club).size
}
end
end end

0 comments on commit ae2baab

Please sign in to comment.