public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
port [9018] to 2.0 stable

git-svn-id: 
http://svn-commit.rubyonrails.org/rails/branches/2-0-stable@9019 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
technoweenie (author)
Wed Mar 12 20:12:23 -0700 2008
commit  b96db528788c2a04ad43c30155d33034ab242212
tree    383201ccd3182b40a79d1f72e727bf58be1769cb
parent  0e57097437f67ce95e43f2e8dda4e5205e1cb82d
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* Ensure that ActiveRecord::Calculations disambiguates field names with the table name. #11027 [cavalle]
0
+
0
 * Ensure that modifying has_and_belongs_to_many actions clear the query cache. Closes #10840 [john.andrews]
0
 
0
 * Fix issue where Table#references doesn't pass a :null option to a *_type attribute for polymorphic associations. Closes #10753 [railsjitsu]
...
155
156
157
 
158
159
160
...
155
156
157
158
159
160
161
0
@@ -155,6 +155,7 @@ module ActiveRecord
0
           scope = scope(:find)
0
           merged_includes = merge_includes(scope ? scope[:include] : [], options[:include])
0
           aggregate_alias = column_alias_for(operation, column_name)
0
+ column_name = "#{connection.quote_table_name(table_name)}.#{column_name}" unless column_name == "*" || column_name.to_s.include?('.')
0
 
0
           if operation == 'count'
0
             if merged_includes.any?
...
536
537
538
 
 
 
 
 
 
 
 
539
540
541
...
536
537
538
539
540
541
542
543
544
545
546
547
548
549
0
@@ -536,6 +536,14 @@ class AssociationsJoinModelTest < Test::Unit::TestCase
0
     assert_nothing_raised { authors(:david).comments.sum(:post_id) }
0
   end
0
 
0
+ def test_calculations_on_has_many_through_should_disambiguate_fields
0
+ assert_nothing_raised { authors(:david).categories.maximum(:id) }
0
+ end
0
+
0
+ def test_calculations_on_has_many_through_should_not_disambiguate_fields_unless_necessary
0
+ assert_nothing_raised { authors(:david).categories.maximum("categories.id") }
0
+ end
0
+
0
   def test_has_many_through_has_many_with_sti
0
     assert_equal [comments(:does_it_hurt)], authors(:david).special_post_comments
0
   end

Comments

    No one has commented yet.