diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-06-20 11:27:18 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-20 11:27:18 -0400 |
commit | 70d3c38447eb93950d3d6d61938fe24b7fccf21f (patch) | |
tree | c90f15207aebabe30e77007e2e49e0fc2f864dee /activerecord/lib/active_record | |
parent | f006edeb940e8636bab012f098f0aa125c72c4a6 (diff) | |
parent | 89d562edbac3a2cfb9f31b1019feed7139cf7067 (diff) | |
download | rails-70d3c38447eb93950d3d6d61938fe24b7fccf21f.tar.gz rails-70d3c38447eb93950d3d6d61938fe24b7fccf21f.tar.bz2 rails-70d3c38447eb93950d3d6d61938fe24b7fccf21f.zip |
Merge pull request #28833 from bogdanvlviv/add-test-cases-for-optimistic-locking
Add test cases for optimistic locking
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/locking/optimistic.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/locking/optimistic.rb b/activerecord/lib/active_record/locking/optimistic.rb index 3c7110369b..f8fcb7ccaa 100644 --- a/activerecord/lib/active_record/locking/optimistic.rb +++ b/activerecord/lib/active_record/locking/optimistic.rb @@ -62,8 +62,8 @@ module ActiveRecord def increment_lock lock_col = self.class.locking_column - previous_lock_value = send(lock_col).to_i - send(lock_col + "=", previous_lock_value + 1) + previous_lock_value = send(lock_col) + send("#{lock_col}=", previous_lock_value + 1) end def _create_record(attribute_names = self.attribute_names, *) @@ -107,7 +107,8 @@ module ActiveRecord # If something went wrong, revert the locking_column value. rescue Exception - send(lock_col + "=", previous_lock_value.to_i) + send("#{lock_col}=", previous_lock_value.to_i) + raise end end |