提交 796574c9 编写于 作者: S Sean Griffin

We don't need additional type casting for locking updates

Part of the larger refactoring to remove type casting from Arel. We can
inform it that we already have the right type by wrapping the value in
an `Arel::Nodes::Quoted`. This commit can be reverted when we have
removed type casting from Arel in Rail 5.1
上级 a61a8568
......@@ -80,10 +80,18 @@ def _update_record(attribute_names = self.attribute_names) #:nodoc:
begin
relation = self.class.unscoped
stmt = relation.where(
relation.table[self.class.primary_key].eq(id).and(
relation.table[lock_col].eq(self.class.quote_value(previous_lock_value, column_for_attribute(lock_col)))
# FIXME: Remove the Arel::Nodes::Quoted when we remove type casting
# from Arel (Rails 5.1)
quoted_lock_value = Arel::Nodes::Quoted.new(
self.class.quote_value(
previous_lock_value,
column_for_attribute(lock_col),
)
)
quoted_id = Arel::Nodes::Quoted.new(id)
stmt = relation.where(
relation.table[self.class.primary_key].eq(quoted_id).and(
relation.table[lock_col].eq(quoted_lock_value))
).arel.compile_update(
arel_attributes_with_values_for_update(attribute_names),
self.class.primary_key
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册