mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Don't guard against touch: []
.
Closes #27683. Seeing a code sample that leads to what we're guarding against: ```ruby Topic.update_counters(1, replies_count: 1, touch: []) ``` It doesn't look like a case people would ever intentionally end up with. Thus we're better off sparing the conditional. Note: it could happen if a method returns an empty array that's then passed to `update_counters` and its touchy friends. But `[].presence` can fix that once people see their query blow up. [ Eugene Kenny & Kasper Timm Hansen ]
This commit is contained in:
parent
1f2a283365
commit
a0a1ede8c2
1 changed files with 1 additions and 2 deletions
|
@ -105,8 +105,7 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
if touch
|
||||
touch_updates = touch_updates(touch)
|
||||
updates << sanitize_sql_for_assignment(touch_updates) unless touch_updates.empty?
|
||||
updates << sanitize_sql_for_assignment(touch_updates(touch))
|
||||
end
|
||||
|
||||
unscoped.where(primary_key => id).update_all updates.join(", ")
|
||||
|
|
Loading…
Reference in a new issue