提交 0fbf829b 编写于 作者: A Aaron Patterson

stop the recursive insanity

上级 34d79fad
......@@ -166,14 +166,19 @@ def update_all(updates, conditions = nil, options = {})
if conditions || options.present?
where(conditions).apply_finder_options(options.slice(:limit, :order)).update_all(updates)
else
limit = nil
order = []
# Apply limit and order only if they're both present
if @limit_value.present? == @order_values.present?
stmt = arel.compile_update(Arel::SqlLiteral.new(@klass.send(:sanitize_sql_for_assignment, updates)))
stmt.key = @klass.arel_table[@klass.primary_key]
@klass.connection.update stmt.to_sql
else
except(:limit, :order).update_all(updates)
limit = arel.limit
order = arel.orders
end
stmt = arel.compile_update(Arel::SqlLiteral.new(@klass.send(:sanitize_sql_for_assignment, updates)))
stmt.take limit
stmt.order(*order)
stmt.key = @klass.arel_table[@klass.primary_key]
@klass.connection.update stmt.to_sql
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册