aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/locking
diff options
context:
space:
mode:
authorVipul A M <vipulnsward@gmail.com>2016-05-01 02:44:52 +0530
committerVipul A M <vipulnsward@gmail.com>2016-05-01 02:44:52 +0530
commit7b37e3edaf25627b6db023be5a1f8bf9733aafdd (patch)
tree6e87b587017353bc2fe074c2fe4a727c23bf1f03 /activerecord/lib/active_record/locking
parent9d1bf059c0a570f68b2394bfb383434a6b0d0a49 (diff)
downloadrails-7b37e3edaf25627b6db023be5a1f8bf9733aafdd.tar.gz
rails-7b37e3edaf25627b6db023be5a1f8bf9733aafdd.tar.bz2
rails-7b37e3edaf25627b6db023be5a1f8bf9733aafdd.zip
Move comment up to the class, for both of the methods, and document on class level why we are doing this.
[ci skip]
Diffstat (limited to 'activerecord/lib/active_record/locking')
-rw-r--r--activerecord/lib/active_record/locking/optimistic.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/locking/optimistic.rb b/activerecord/lib/active_record/locking/optimistic.rb
index 1e37ffefc6..67b8efac66 100644
--- a/activerecord/lib/active_record/locking/optimistic.rb
+++ b/activerecord/lib/active_record/locking/optimistic.rb
@@ -184,9 +184,12 @@ module ActiveRecord
end
end
+
+ # In de/serialize we change `nil` to 0, so that we can allow passing
+ # `nil` values to `lock_version`, and not result in `ActiveRecord::StaleObjectError`
+ # during update record.
class LockingType < DelegateClass(Type::Value) # :nodoc:
def deserialize(value)
- # `nil` *should* be changed to 0
super.to_i
end