Ticket #11517: eager_include_with_order_on_aliased_table_name_and_limit.patch
| File eager_include_with_order_on_aliased_table_name_and_limit.patch, 1.4 kB (added by jonathan_viney, 4 months ago) |
|---|
-
test/cases/associations/eager_test.rb
old new 177 177 end 178 178 end 179 179 180 def test_eager_association_with_order_on_aliased_table_name_and_limit 181 Author.find(:first, :include => [:comments, :funky_comments], :order => 'funky_comments_authors.id', :limit => 1) 182 end 183 180 184 def test_eager_association_loading_with_belongs_to_and_limit_and_multiple_associations 181 185 posts = Post.find(:all, :include => [:author, :very_special_comment], :limit => 1, :order => 'posts.id') 182 186 assert_equal 1, posts.length -
lib/active_record/associations.rb
old new 1437 1437 sql << " FROM #{connection.quote_table_name table_name} " 1438 1438 1439 1439 if is_distinct 1440 sql << join_dependency.join_associations.reject{ |ja| !all_tables.include?(ja. table_name) }.collect(&:association_join).join1440 sql << join_dependency.join_associations.reject{ |ja| !all_tables.include?(ja.aliased_table_name) }.collect(&:association_join).join 1441 1441 add_joins!(sql, options, scope) 1442 1442 end 1443 1443