aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-04-06 16:16:29 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-04-06 16:16:29 +0000
commit8eb73f43e1f7eb6f7afa7838e64b259c81bc8a47 (patch)
tree2a00f89e62559f843786a9101016dbce1e1ed8b7
parent64003677b7063aabc2a943e75e56b48cae6b15f7 (diff)
downloadrails-8eb73f43e1f7eb6f7afa7838e64b259c81bc8a47.tar.gz
rails-8eb73f43e1f7eb6f7afa7838e64b259c81bc8a47.tar.bz2
rails-8eb73f43e1f7eb6f7afa7838e64b259c81bc8a47.zip
Fixed that that multiparameter assignment doesn't work with aggregations (closes #4620) [Lars Pind]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4188 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--activerecord/CHANGELOG4
-rwxr-xr-xactiverecord/lib/active_record/base.rb2
-rwxr-xr-xactiverecord/test/base_test.rb9
-rw-r--r--activerecord/test/fixtures/customer.rb4
4 files changed, 17 insertions, 2 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 8a68f37d12..672a0f4f05 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,6 +1,8 @@
+*1.14.1* (April 6th, 2005)
+
* Fix type_name_with_module to handle type names that begin with '::'. Closes #4614. [Nicholas Seckar]
-*1.14.1* (April 6th, 2005)
+* Fixed that that multiparameter assignment doesn't work with aggregations (closes #4620) [Lars Pind]
* Enable Limit/Offset in Calculations (closes #4558) [lmarlow@yahoo.com]
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index b91ebafee5..106432ed9e 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1988,7 +1988,7 @@ module ActiveRecord #:nodoc:
def execute_callstack_for_multiparameter_attributes(callstack)
errors = []
callstack.each do |name, values|
- klass = (self.class.reflect_on_aggregation(name) || column_for_attribute(name)).klass
+ klass = (self.class.reflect_on_aggregation(name.to_sym) || column_for_attribute(name)).klass
if values.empty?
send(name + "=", nil)
else
diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb
index 391ee57632..63bc3ea6a2 100755
--- a/activerecord/test/base_test.rb
+++ b/activerecord/test/base_test.rb
@@ -2,6 +2,7 @@ require 'abstract_unit'
require 'fixtures/topic'
require 'fixtures/reply'
require 'fixtures/company'
+require 'fixtures/customer'
require 'fixtures/developer'
require 'fixtures/project'
require 'fixtures/default'
@@ -721,6 +722,14 @@ class BasicsTest < Test::Unit::TestCase
task.attributes = attributes
assert_equal time, task.starting
end
+
+ def test_multiparameter_assignment_of_aggregation
+ customer = Customer.new
+ address = Address.new("The Street", "The City", "The Country")
+ attributes = { "address(1)" => address.street, "address(2)" => address.city, "address(3)" => address.country }
+ customer.attributes = attributes
+ assert_equal address, customer.address
+ end
def test_attributes_on_dummy_time
# Oracle and SQL Server do not have a TIME datatype.
diff --git a/activerecord/test/fixtures/customer.rb b/activerecord/test/fixtures/customer.rb
index 2eba052eee..e23fd03ade 100644
--- a/activerecord/test/fixtures/customer.rb
+++ b/activerecord/test/fixtures/customer.rb
@@ -14,6 +14,10 @@ class Address
def close_to?(other_address)
city == other_address.city && country == other_address.country
end
+
+ def ==(other)
+ other.is_a?(self.class) && other.street == street && other.city == city && other.country == country
+ end
end
class Money