Skip to content

Fix touch option to behave consistently with Persistence#touch method#33107

Merged
kamipo merged 1 commit into
rails:masterfrom
kamipo:counter_cache_with_touch
Jun 18, 2018
Merged

Fix touch option to behave consistently with Persistence#touch method#33107
kamipo merged 1 commit into
rails:masterfrom
kamipo:counter_cache_with_touch

Conversation

@kamipo

@kamipo kamipo commented Jun 10, 2018

Copy link
Copy Markdown
Member

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.

…thod

`touch` option was added to `increment!` (rails#27660) and `update_counters`
(rails#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, rails#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.
@kamipo
kamipo merged commit cad0b7d into rails:master Jun 18, 2018
@kamipo
kamipo deleted the counter_cache_with_touch branch June 18, 2018 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants