diff options
author | Rick Olson <technoweenie@gmail.com> | 2006-03-18 07:31:01 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2006-03-18 07:31:01 +0000 |
commit | 229c0f4367be3c766886d75b51e3c15ee8916fc2 (patch) | |
tree | 47bcb766fefb4f808406f1ec8a1b52eb345b06b6 /activerecord/test/associations_cascaded_eager_loading_test.rb | |
parent | f1a350a05c97d6e54e6dde26c101e8035d55e40c (diff) | |
download | rails-229c0f4367be3c766886d75b51e3c15ee8916fc2.tar.gz rails-229c0f4367be3c766886d75b51e3c15ee8916fc2.tar.bz2 rails-229c0f4367be3c766886d75b51e3c15ee8916fc2.zip |
Rework table aliasing to account for truncated table aliases. Add smarter table aliasing when doing eager loading of STI associations. This allows you to use the association name in the order/where clause. [Jonathan Viney / Rick Olson] closes #4108
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3921 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/associations_cascaded_eager_loading_test.rb')
-rw-r--r-- | activerecord/test/associations_cascaded_eager_loading_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/associations_cascaded_eager_loading_test.rb b/activerecord/test/associations_cascaded_eager_loading_test.rb index 8f0a41f593..166d2b2262 100644 --- a/activerecord/test/associations_cascaded_eager_loading_test.rb +++ b/activerecord/test/associations_cascaded_eager_loading_test.rb @@ -85,4 +85,22 @@ class CascadedEagerLoadingTest < Test::Unit::TestCase assert_equal [topics(:second)], replies assert_equal topics(:first), assert_no_queries { replies.first.topic } end + + def test_eager_association_loading_with_multiple_stis_and_order + author = Author.find(:first, :include => { :posts => [ :special_comments , :very_special_comment ] }, :order => 'authors.name, special_comments.body, very_special_comments.body', :conditions => 'posts.id = 4') + assert_equal authors(:david), author + assert_no_queries do + author.posts.first.special_comments + author.posts.first.very_special_comment + end + end + + def test_eager_association_loading_of_stis_with_multiple_references + authors = Author.find(:all, :include => { :posts => { :special_comments => { :post => [ :special_comments, :very_special_comment ] } } }, :order => 'special_comments.body, very_special_comments.body', :conditions => 'posts.id = 4') + assert_equal [authors(:david)], authors + assert_no_queries do + authors.first.posts.first.special_comments.first.post.special_comments + authors.first.posts.first.special_comments.first.post.very_special_comment + end + end end |