Permalink
Browse files

Calculations don't modify their options hash. References [5931], [542…

…6], closes #6929.

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-pre-release@5932 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 2d5bf4b commit 5385859dcf26cd4f0e934f16f390a37aae76afda @jeremy jeremy committed Jan 14, 2007
Showing with 11 additions and 0 deletions.
  1. +3 −0 activerecord/lib/active_record/calculations.rb
  2. +8 −0 activerecord/test/calculations_test.rb
@@ -157,6 +157,9 @@ def construct_count_options_from_legacy_args(*args)
end
def construct_calculation_sql(operation, column_name, options) #:nodoc:
+ operation = operation.to_s.downcase
+ options = options.symbolize_keys
+
scope = scope(:find)
merged_includes = merge_includes(scope ? scope[:include] : [], options[:include])
aggregate_alias = column_alias_for(operation, column_name)
@@ -131,6 +131,14 @@ def test_should_calculate_grouped_association_with_invalid_field
assert_equal 2, c[companies(:rails_core)]
assert_equal 1, c[companies(:first_client)]
end
+
+ def test_should_not_modify_options_when_using_includes
+ options = {:conditions => 'companies.id > 1', :include => :firm}
+ options_copy = options.dup
+
+ Account.count(:all, options)
+ assert_equal options_copy, options
+ end
def test_should_calculate_grouped_by_function
c = Company.count(:all, :group => "UPPER(#{QUOTED_TYPE})")

0 comments on commit 5385859

Please sign in to comment.