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

Changeset 9018

Show
Ignore:
Timestamp:
03/13/08 03:06:51 (6 months ago)
Author:
rick
Message:

Ensure that ActiveRecord::Calculations disambiguates field names with the table name. Closes #11027 [cavalle]

Files:

Legend:

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

    r9014 r9018  
    11*SVN* 
     2 
     3* Ensure that ActiveRecord::Calculations disambiguates field names with the table name.  #11027 [cavalle] 
    24 
    35* Added add/remove_timestamps to the schema statements for adding the created_at/updated_at columns on existing tables #11129 [jramirez] 
  • trunk/activerecord/lib/active_record/calculations.rb

    r8778 r9018  
    156156          merged_includes = merge_includes(scope ? scope[:include] : [], options[:include]) 
    157157          aggregate_alias = column_alias_for(operation, column_name) 
     158          column_name     = "#{connection.quote_table_name(table_name)}.#{column_name}" unless column_name == "*" || column_name.to_s.include?('.') 
    158159 
    159160          if operation == 'count' 
  • trunk/activerecord/test/cases/associations/join_model_test.rb

    r8957 r9018  
    545545  end 
    546546 
     547  def test_calculations_on_has_many_through_should_disambiguate_fields 
     548    assert_nothing_raised { authors(:david).categories.maximum(:id) } 
     549  end 
     550   
     551  def test_calculations_on_has_many_through_should_not_disambiguate_fields_unless_necessary 
     552    assert_nothing_raised { authors(:david).categories.maximum("categories.id") } 
     553  end 
     554 
    547555  def test_has_many_through_has_many_with_sti 
    548556    assert_equal [comments(:does_it_hurt)], authors(:david).special_post_comments