Skip to content


Fix ActiveRecord#update_column return value #8083

merged 1 commit into from

5 participants


I think I have a fix for incorrect return value from ActiveRecord#update_column method.

@josevalim josevalim merged commit f5f57e2 into rails:3-2-stable

The return value is not guaranteed to be a singleton, we should just test

assert return_value
Ruby on Rails member

We need a CHANGELOG entry for this

Ruby on Rails member

@spastorino is it really necessary in this case, since it was added right before the rc1 was released, in cherry pick cdfa4a5?

Ruby on Rails member

@carlosantoniodasilva got it, I doesn't need a CHANGELOG entry just an entry in rc2 release changelog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 31, 2012
  1. @saks
Showing with 7 additions and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/persistence.rb
  2. +6 −0 activerecord/test/cases/persistence_test.rb
2 activerecord/lib/active_record/persistence.rb
@@ -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)
6 activerecord/test/cases/persistence_test.rb
@@ -513,6 +513,12 @@ def test_update_column_changing_id
assert_equal 123,
+ 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?
Something went wrong with that request. Please try again.