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

Changeset 7494

Show
Ignore:
Timestamp:
09/15/07 23:50:12 (1 year ago)
Author:
bitsweat
Message:

Eager loading respects explicit :joins. Closes #9496.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/CHANGELOG

    r7492 r7494  
    11*SVN* 
     2 
     3* Eager loading respects explicit :joins.  #9496 [dasil003] 
    24 
    35* Extract Firebird, FronBase, and OpenBase adapters into gems.  #9508, #9509, #9510 [Jeremy Kemper] 
  • trunk/activerecord/lib/active_record/associations.rb

    r7402 r7494  
    12671267        def construct_finder_sql_for_association_limiting(options, join_dependency) 
    12681268          scope       = scope(:find) 
    1269           is_distinct = include_eager_conditions?(options) || include_eager_order?(options) 
     1269          is_distinct = !options[:joins].blank? || include_eager_conditions?(options) || include_eager_order?(options) 
    12701270          sql = "SELECT " 
    12711271          if is_distinct 
  • trunk/activerecord/test/associations/eager_test.rb

    r7472 r7494  
    102102    assert_equal 1, posts.length 
    103103    assert_equal [2], posts.collect { |p| p.id } 
     104  end 
     105   
     106  def test_eager_association_loading_with_explicit_join 
     107    posts = Post.find(:all, :include => :comments, :joins => "INNER JOIN authors ON posts.author_id = authors.id AND authors.name = 'Mary'", :limit => 1, :order => 'author_id') 
     108    assert_equal 1, posts.length 
    104109  end 
    105110