diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-03-04 01:56:49 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-03-05 09:52:58 +0900 |
commit | 37984353f272efb12cb1d008cb231a1f1e56524a (patch) | |
tree | d6dd4d4910f1867befdce0eb6c87353c2b0977c6 /activerecord/lib/active_record/locking | |
parent | 4331478996d6086bb089c1e33956a1c0fa9000b1 (diff) | |
download | rails-37984353f272efb12cb1d008cb231a1f1e56524a.tar.gz rails-37984353f272efb12cb1d008cb231a1f1e56524a.tar.bz2 rails-37984353f272efb12cb1d008cb231a1f1e56524a.zip |
Prefer `_update_record` than `update_all` for updating a record
Diffstat (limited to 'activerecord/lib/active_record/locking')
-rw-r--r-- | activerecord/lib/active_record/locking/optimistic.rb | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/locking/optimistic.rb b/activerecord/lib/active_record/locking/optimistic.rb index cae7a66fcc..c2f740a1e0 100644 --- a/activerecord/lib/active_record/locking/optimistic.rb +++ b/activerecord/lib/active_record/locking/optimistic.rb @@ -91,13 +91,10 @@ module ActiveRecord attribute_names.push(lock_col) - relation = self.class.unscoped - - affected_rows = relation.where( + affected_rows = self.class._update_record( + attributes_with_values_for_update(attribute_names), self.class.primary_key => id_in_database, lock_col => previous_lock_value - ).update_all( - attributes_with_values_for_update(attribute_names) ) unless affected_rows == 1 |