Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7327

Show
Ignore:
Timestamp:
08/16/07 04:58:06 (1 year ago)
Author:
nzkoz
Message:

Merge [7235] to stable. References #9167 [danger]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1-2-stable/activerecord/CHANGELOG

    r7076 r7327  
    11*SVN* 
     2 
     3* Make sure has_many uses :include when counting [danger] 
    24 
    35* 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  
    139139            @reflection.klass.count_by_sql(@counter_sql) 
    140140          else 
    141             @reflection.klass.count(:conditions => @counter_sql
     141            @reflection.klass.count(:conditions => @counter_sql, :include => @reflection.options[:include]
    142142          end 
    143143           
  • branches/1-2-stable/activerecord/test/associations/eager_test.rb

    r5888 r7327  
    271271    assert_not_nil f.account 
    272272    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 
    273280  end 
    274281 
  • branches/1-2-stable/activerecord/test/fixtures/author.rb

    r5305 r7327  
    2626  has_many :hello_posts, :class_name => "Post", :conditions => "posts.body = 'hello'" 
    2727  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 
    2829 
    2930  has_many :other_posts,          :class_name => "Post"