aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/persistence.rb
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-10-28 13:31:34 -0700
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-10-28 13:31:34 -0700
commitc6f47c198034ed2031723a16069005b321846452 (patch)
tree6e741da75ee9246fc85ca6bc1c222c7169681690 /activerecord/lib/active_record/persistence.rb
parent5bbe245a51cec029101c844e159ba7f7a7afedab (diff)
parent1849665f738cf7b3650e508b05380ebb36748f9e (diff)
downloadrails-c6f47c198034ed2031723a16069005b321846452.tar.gz
rails-c6f47c198034ed2031723a16069005b321846452.tar.bz2
rails-c6f47c198034ed2031723a16069005b321846452.zip
Merge pull request #8053 from henrik/update_columns_with_primary_key
Unbreak update_column/update_columns for the primary key attribute.
Diffstat (limited to 'activerecord/lib/active_record/persistence.rb')
-rw-r--r--activerecord/lib/active_record/persistence.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index 611d3d97c3..c336e1f5bb 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -224,11 +224,13 @@ module ActiveRecord
verify_readonly_attribute(key.to_s)
end
+ updated_count = self.class.where(self.class.primary_key => id).update_all(attributes)
+
attributes.each do |k,v|
raw_write_attribute(k,v)
end
- self.class.where(self.class.primary_key => id).update_all(attributes) == 1
+ updated_count == 1
end
# Initializes +attribute+ to zero if +nil+ and adds the value passed as +by+ (default is 1).