diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-12-28 17:03:37 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-12-28 17:03:37 -0800 |
commit | 780a222dc2e888646aba4b6908ea78dba9d50722 (patch) | |
tree | 37a07bdd0dd87f3bacd7aa678ca6e2b91f5db9e0 /activerecord/test | |
parent | f06074f365932f47e108004b93f05b259cf0c5db (diff) | |
parent | 18fb2d4c022c1d95dc9a40493adbc3880da70dcd (diff) | |
download | rails-780a222dc2e888646aba4b6908ea78dba9d50722.tar.gz rails-780a222dc2e888646aba4b6908ea78dba9d50722.tar.bz2 rails-780a222dc2e888646aba4b6908ea78dba9d50722.zip |
Merge pull request #4216 from edgecase/master_fix_reorder_with_limited_ids
allow reorder to affect eager loading correctly
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/has_many_associations_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index 88d7d47aea..f1a341437f 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -57,6 +57,16 @@ class HasManyAssociationsTestForCountDistinctWithFinderSql < ActiveRecord::TestC end end +class HasManyAssociationsTestForReorderWithJoinDependency < ActiveRecord::TestCase + fixtures :authors, :posts, :comments + + def test_should_generate_valid_sql + author = authors(:david) + # this can fail on adapters which require ORDER BY expressions to be included in the SELECT expression + # if the reorder clauses are not correctly handled + assert author.posts_with_comments_sorted_by_comment_id.where('comments.id > 0').reorder('posts.comments_count DESC', 'posts.taggings_count DESC').last + end +end class HasManyAssociationsTest < ActiveRecord::TestCase |