New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clear @cache_keys
cache after update_all
, delete_all
, destroy_all
#41789
Conversation
…all` The calculated cache key is cached on a relation, but there is no way to re-calculation even if mutation to collection on a relation is happened. The `@cache_keys` cache should be cleared at least after `update_all`, `delete_all`, `destroy_all`. Related to rails#41784.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find tap
very confusing, but up to you if you are going to use it
There are two main reasons why I've used The first one is rails/activerecord/lib/active_record/relation.rb Lines 577 to 579 in 5b10aca
The second one is that I'd not like to name what the return value of The return value of If there is no strong objection to those points, I would like to continue to use it here. |
Like I said it is up to you. But |
I see your point. Just as the In the meantime, leave this idiom as it is for now. |
Clear `@cache_keys` cache after `update_all`, `delete_all`, `destroy_all`
Call `reset` after bulk inserts and upserts to discard stale data. This matches the behavior of `update_all` added in rails#41789.
The calculated cache key is cached on a relation, but there is no way to
re-calculation even if mutation to collection on a relation is happened.
The
@cache_keys
cache should be cleared at least afterupdate_all
,delete_all
,destroy_all
.Related to #41784.