Please sign in to comment.
Fix `touch` option to behave consistently with `Persistence#touch` me…
…thod `touch` option was added to `increment!` (#27660) and `update_counters` (#26995). But that option behaves inconsistently with `Persistence#touch` method. If `touch` option is passed attribute names, it won't update update_at/on attributes unlike `Persistence#touch` method. Due to changed from `Persistence#touch` to `increment!` with `touch` option, #31405 has a regression that `counter_cache` with `touch` option which is passed attribute names won't update update_at/on attributes. I think that the inconsistency is not intended. To get back consistency, ensure that `touch` option updates update_at/on attributes.
- Loading branch information...
Showing with 98 additions and 51 deletions.
- +4 −0 activerecord/CHANGELOG.md
- +10 −12 activerecord/lib/active_record/counter_cache.rb
- +1 −4 activerecord/lib/active_record/relation.rb
- +14 −8 activerecord/lib/active_record/timestamp.rb
- +6 −6 activerecord/test/cases/counter_cache_test.rb
- +15 −9 activerecord/test/cases/locking_test.rb
- +42 −10 activerecord/test/cases/persistence_test.rb
- +2 −0 activerecord/test/models/car.rb
- +1 −1 activerecord/test/models/wheel.rb
- +3 −1 activerecord/test/schema/schema.rb
|@@ -1,5 +1,5 @@|
|# frozen_string_literal: true|
|class Wheel < ActiveRecord::Base|
|belongs_to :wheelable, polymorphic: true, counter_cache: true, touch: true|
|belongs_to :wheelable, polymorphic: true, counter_cache: true, touch: :wheels_owned_at|