aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/locking
diff options
context:
space:
mode:
authorbogdanvlviv <bogdanvlviv@gmail.com>2016-08-22 21:16:08 +0300
committerbogdanvlviv <bogdanvlviv@gmail.com>2016-10-21 19:06:02 +0300
commita60a20bb7faae4d0758676b865f625275c500e4e (patch)
treeb397dd02111aaf30d6e042a66a20ad0d27669500 /activerecord/lib/active_record/locking
parent22a822e5813ef7ea9ab6dbbb670a363899a083af (diff)
downloadrails-a60a20bb7faae4d0758676b865f625275c500e4e.tar.gz
rails-a60a20bb7faae4d0758676b865f625275c500e4e.tar.bz2
rails-a60a20bb7faae4d0758676b865f625275c500e4e.zip
Added ability update locking_column value
Diffstat (limited to 'activerecord/lib/active_record/locking')
-rw-r--r--activerecord/lib/active_record/locking/optimistic.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/locking/optimistic.rb b/activerecord/lib/active_record/locking/optimistic.rb
index fa9e789b24..d39b7181f4 100644
--- a/activerecord/lib/active_record/locking/optimistic.rb
+++ b/activerecord/lib/active_record/locking/optimistic.rb
@@ -78,17 +78,19 @@ module ActiveRecord
def _update_record(attribute_names = self.attribute_names) #:nodoc:
return super unless locking_enabled?
- return 0 if attribute_names.empty?
lock_col = self.class.locking_column
- previous_lock_value = read_attribute_before_type_cast(lock_col)
-
- increment_lock
- attribute_names += [lock_col]
- attribute_names.uniq!
+ return super if attribute_names.include?(lock_col)
+ return 0 if attribute_names.empty?
begin
+ previous_lock_value = read_attribute_before_type_cast(lock_col)
+
+ increment_lock
+
+ attribute_names.push(lock_col)
+
relation = self.class.unscoped
affected_rows = relation.where(