diff options
author | Sean Griffin <sean@thoughtbot.com> | 2015-01-14 15:25:15 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2015-01-14 15:25:15 -0700 |
commit | df73d696f5a965b67c9f177bf4dd8d85921d0214 (patch) | |
tree | a55920155a6f7301cf4250f8589faf7c46b27cce /activerecord/lib/active_record/locking | |
parent | 9a21774d73ebb1eece5ef29d71de17147be99992 (diff) | |
download | rails-df73d696f5a965b67c9f177bf4dd8d85921d0214.tar.gz rails-df73d696f5a965b67c9f177bf4dd8d85921d0214.tar.bz2 rails-df73d696f5a965b67c9f177bf4dd8d85921d0214.zip |
Go through normal where logic in destroy with locking
Building the Arel AST, and manipulating the relation manually like this
is prone to errors and breakage as implementation details change from
underneath it.
Diffstat (limited to 'activerecord/lib/active_record/locking')
-rw-r--r-- | activerecord/lib/active_record/locking/optimistic.rb | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/locking/optimistic.rb b/activerecord/lib/active_record/locking/optimistic.rb index aeb1a4ddc6..6f2b65c137 100644 --- a/activerecord/lib/active_record/locking/optimistic.rb +++ b/activerecord/lib/active_record/locking/optimistic.rb @@ -125,12 +125,8 @@ module ActiveRecord relation = super if locking_enabled? - column_name = self.class.locking_column - column = self.class.columns_hash[column_name] - substitute = self.class.connection.substitute_at(column) - - relation = relation.where(self.class.arel_table[column_name].eq(substitute)) - relation.bind_values << [column, self[column_name].to_i] + locking_column = self.class.locking_column + relation = relation.where(locking_column => _read_attribute(locking_column)) end relation |