aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorErnie Miller <ernie@metautonomo.us>2010-04-28 23:14:05 -0400
committerJeremy Kemper <jeremy@bitsweat.net>2010-04-28 20:28:51 -0700
commite33d304975f5b20b0ba819ab644a2a8f80ff3743 (patch)
treebd5e6fa6491a61d19aa4c79c5ee85b53769e7137 /activerecord/test
parent4e75cc59e70947b794c96894d39c015f9e1cb96c (diff)
downloadrails-e33d304975f5b20b0ba819ab644a2a8f80ff3743.tar.gz
rails-e33d304975f5b20b0ba819ab644a2a8f80ff3743.tar.bz2
rails-e33d304975f5b20b0ba819ab644a2a8f80ff3743.zip
Fix eager loading of associations causing table name collisions
[#4463 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/associations/cascaded_eager_loading_test.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/cascaded_eager_loading_test.rb b/activerecord/test/cases/associations/cascaded_eager_loading_test.rb
index ed2e2e9f8f..fe558f9d3b 100644
--- a/activerecord/test/cases/associations/cascaded_eager_loading_test.rb
+++ b/activerecord/test/cases/associations/cascaded_eager_loading_test.rb
@@ -29,6 +29,15 @@ class CascadedEagerLoadingTest < ActiveRecord::TestCase
assert_equal 2, authors[1].categorizations.size
end
+ def test_eager_association_loading_with_hmt_does_not_table_name_collide_when_joining_associations
+ assert_nothing_raised do
+ Author.joins(:posts).eager_load(:comments).where(:posts => {:taggings_count => 1}).all
+ end
+ authors = Author.joins(:posts).eager_load(:comments).where(:posts => {:taggings_count => 1}).all
+ assert_equal 1, assert_no_queries { authors.size }
+ assert_equal 9, assert_no_queries { authors[0].comments.size }
+ end
+
def test_eager_association_loading_with_cascaded_two_levels_with_two_has_many_associations
authors = Author.find(:all, :include=>{:posts=>[:comments, :categorizations]}, :order=>"authors.id")
assert_equal 2, authors.size