From 236f0bb67adecbc1e6dac5258e4a8cb310ffd7a4 Mon Sep 17 00:00:00 2001 From: Frederick Cheung Date: Wed, 7 May 2008 00:12:17 +0100 Subject: When preloading group by reflection rather than by class [#125 state:resolved] This avoids extra queries when several subclasses inherit the association from their parent class, while still coping with subclasses redefining associations. Signed-off-by: Pratik Naik --- activerecord/test/cases/associations/eager_test.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'activerecord/test/cases/associations/eager_test.rb') diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index fb8deedf95..3a3358e39b 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -603,4 +603,10 @@ class EagerAssociationTest < ActiveRecord::TestCase assert_equal 3, authors(:david).posts_with_comments.count(:conditions => "length(comments.body) > 15") end end + + def test_load_with_sti_sharing_association + assert_queries(2) do #should not do 1 query per subclass + Comment.find :all, :include => :post + end + end end -- cgit v1.2.3