Changeset 7327
- Timestamp:
- 08/16/07 04:58:06 (1 year ago)
- Files:
-
- branches/1-2-stable/activerecord/CHANGELOG (modified) (1 diff)
- branches/1-2-stable/activerecord/lib/active_record/associations/has_many_association.rb (modified) (1 diff)
- branches/1-2-stable/activerecord/test/associations/eager_test.rb (modified) (1 diff)
- branches/1-2-stable/activerecord/test/fixtures/author.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1-2-stable/activerecord/CHANGELOG
r7076 r7327 1 1 *SVN* 2 3 * Make sure has_many uses :include when counting [danger] 2 4 3 5 * Save associated records only if the association is already loaded. #8713 [blaine] branches/1-2-stable/activerecord/lib/active_record/associations/has_many_association.rb
r5359 r7327 139 139 @reflection.klass.count_by_sql(@counter_sql) 140 140 else 141 @reflection.klass.count(:conditions => @counter_sql )141 @reflection.klass.count(:conditions => @counter_sql, :include => @reflection.options[:include]) 142 142 end 143 143 branches/1-2-stable/activerecord/test/associations/eager_test.rb
r5888 r7327 271 271 assert_not_nil f.account 272 272 assert_equal companies(:first_firm, :reload).account, f.account 273 end 274 275 def test_eager_with_multi_table_conditional_properly_counts_the_records_when_using_size 276 author = authors(:david) 277 posts_with_no_comments = author.posts.select { |post| post.comments.blank? } 278 assert_equal posts_with_no_comments.size, author.posts_with_no_comments.size 279 assert_equal posts_with_no_comments, author.posts_with_no_comments 273 280 end 274 281 branches/1-2-stable/activerecord/test/fixtures/author.rb
r5305 r7327 26 26 has_many :hello_posts, :class_name => "Post", :conditions => "posts.body = 'hello'" 27 27 has_many :hello_post_comments, :through => :hello_posts, :source => :comments 28 has_many :posts_with_no_comments, :class_name => 'Post', :conditions => 'comments.id is null', :include => :comments 28 29 29 30 has_many :other_posts, :class_name => "Post"