Ticket #9175: eager_count_performed_on_a_has_many_association_with_multi_table_conditional.diff
| File eager_count_performed_on_a_has_many_association_with_multi_table_conditional.diff, 1.6 kB (added by danger, 3 years ago) |
|---|
-
activerecord/test/associations/eager_test.rb
old new 168 168 posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :conditions => "posts.title = 'magic forest'") 169 169 assert_equal 0, posts.size 170 170 end 171 172 def test_eager_count_performed_on_a_has_many_association_with_multi_table_conditional 173 author = authors(:david) 174 author_posts_without_comments = author.posts.select { |post| post.comments.blank? } 175 assert_equal author_posts_without_comments.size, author.posts.count(:all, :include => :comments, :conditions => 'comments.id is null') 176 end 171 177 172 178 def test_eager_with_has_and_belongs_to_many_and_limit 173 179 posts = Post.find(:all, :include => :categories, :order => "posts.id", :limit => 3) -
activerecord/lib/active_record/associations/has_many_association.rb
old new 31 31 options[:conditions] = options[:conditions].nil? ? 32 32 @finder_sql : 33 33 @finder_sql + " AND (#{sanitize_sql(options[:conditions])})" 34 options[:include] = @reflection.options[:include]34 options[:include] ||= @reflection.options[:include] 35 35 36 36 @reflection.klass.count(column_name, options) 37 37 end