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

Ticket #11424: generate_valid_sql_on_deeply_nested_tables_and_association_limiting.diff

File generate_valid_sql_on_deeply_nested_tables_and_association_limiting.diff, 1.6 kB (added by danger, 8 months ago)
  • activerecord/test/cases/associations/cascaded_eager_loading_test.rb

    old new  
    5858    assert_equal companies(:first_firm).account, assert_no_queries { firms.first.account.firm.account } 
    5959    assert_equal companies(:first_firm).account.firm.account, assert_no_queries { firms.first.account.firm.account } 
    6060  end 
     61   
     62  def test_eager_association_loading_with_condition_on_cascaded_table_generates_valid_sql 
     63    assert_nothing_raised { Author.find(:all, :include => {:posts => :comments}, :conditions => "comments.body LIKE '%hello%'", :limit => 10) } 
     64  end 
    6165 
    6266  def test_eager_association_loading_with_has_many_sti 
    6367    topics = Topic.find(:all, :include => :replies, :order => 'topics.id') 
  • activerecord/lib/active_record/associations.rb

    old new  
    14371437          sql << " FROM #{connection.quote_table_name table_name} " 
    14381438 
    14391439          if is_distinct 
    1440             sql << join_dependency.join_associations.reject{ |ja| !all_tables.include?(ja.table_name) }.collect(&:association_join).join 
     1440            sql << join_dependency.join_associations.collect(&:association_join).join 
    14411441            add_joins!(sql, options, scope) 
    14421442          end 
    14431443