diff options
author | Marc Schütz <schuetzm@gmx.net> | 2016-07-18 12:37:30 +0200 |
---|---|---|
committer | Marc Schütz <schuetzm@gmx.net> | 2017-02-07 16:29:16 +0100 |
commit | 578f283012f2f047b9e79ac046a32fd51e274761 (patch) | |
tree | b0a7c12768b3ae150e08bc7726bdb649a46764db /activerecord/lib | |
parent | adaa35890b52fe491827a3ab295900c21f35df6f (diff) | |
download | rails-578f283012f2f047b9e79ac046a32fd51e274761.tar.gz rails-578f283012f2f047b9e79ac046a32fd51e274761.tar.bz2 rails-578f283012f2f047b9e79ac046a32fd51e274761.zip |
Deprecate locking of dirty records
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/locking/pessimistic.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/locking/pessimistic.rb b/activerecord/lib/active_record/locking/pessimistic.rb index e73cb4fc12..263e2a5f7f 100644 --- a/activerecord/lib/active_record/locking/pessimistic.rb +++ b/activerecord/lib/active_record/locking/pessimistic.rb @@ -59,7 +59,16 @@ module ActiveRecord # or pass true for "FOR UPDATE" (the default, an exclusive row lock). Returns # the locked record. def lock!(lock = true) - reload(lock: lock) if persisted? + if persisted? + if changed? + ActiveSupport::Deprecation.warn(<<-MSG.squish) + Locking a record with unpersisted changes is deprecated and will raise an + exception in Rails 5.2. Use `save` to persist the changes, or `reload` to + discard them explicitly. + MSG + end + reload(lock: lock) + end self end |