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

Ticket #8838: eager_loading_fails_with_inner_join.diff

File eager_loading_fails_with_inner_join.diff, 0.9 kB (added by andrej, 1 year ago)
  • activerecord/test/associations/eager_test.rb

    old new  
    390390      assert_equal 3, authors(:david).posts_with_comments.count(:conditions => "length(comments.body) > 15") 
    391391    end 
    392392  end 
     393   
     394  def test_eager_load_with_inner_join 
     395    assert_not_nil posts(:welcome) 
     396    assert posts(:welcome).people.size > 0 
     397    assert posts(:welcome).people.find(:all).size > 0 
     398    id = posts(:welcome).id 
     399    assert_equal posts(:welcome).people.find(:all).size, posts(:welcome).people.find(:all, :include => :posts).size 
     400    assert_equal posts(:welcome).people.find(:all).size, People.find(:all, :include => :posts, :joins => 'inner join readers on readers.person_id = people.person_id', :conditions => ['readers.post_id = ?',id]).size 
     401  end 
     402   
    393403end