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.
This commit is contained in:
Sean Griffin 2015-01-14 15:25:15 -07:00
parent 9a21774d73
commit df73d696f5

@ -125,12 +125,8 @@ def relation_for_destroy
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