Fix ActiveRecord#update_column return value #8083

Merged
merged 1 commit into from Oct 31, 2012
Jump to file or symbol
Failed to load files and symbols.
+7 −1
Diff settings

Always

Just for now

@@ -194,7 +194,7 @@ def update_column(name, value)
raise ActiveRecordError, "#{name} is marked as readonly" if self.class.readonly_attributes.include?(name)
raise ActiveRecordError, "can not update on a new record object" unless persisted?
- updated_count = self.class.update_all({ name => value }, self.class.primary_key => id) == 1
+ updated_count = self.class.update_all({ name => value }, self.class.primary_key => id)
raw_write_attribute(name, value)
@@ -513,6 +513,12 @@ def test_update_column_changing_id
assert_equal 123, topic.id
end
+ def test_update_column_should_return_correct_value
+ developer = Developer.find(1)
+ return_value = developer.update_column(:salary, 80001)
+ assert_equal return_value, true
+ end
+
def test_update_attributes
topic = Topic.find(1)
assert !topic.approved?