-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Properly check whether columns are counter cache in order to display them or not #7347
base: master
Are you sure you want to change the base?
Conversation
b3a94a4
to
953377b
Compare
I think I would have rather wanted an attribute to an existing model but I’m fine with either approach. Can you please rebase @plashchynski and we’ll merge this? Thank you. |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #7347 +/- ##
=======================================
Coverage 99.47% 99.47%
=======================================
Files 308 308
Lines 11306 11334 +28
=======================================
+ Hits 11247 11275 +28
Misses 59 59
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
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.
Since we have parallel tests, I don't want to do the "@changes-db-schema" rollback approach so we can just update an existing model with the cache counter.
counter_cache_columns = resource_class.reflect_on_all_associations(:has_many) | ||
.select(&:has_cached_counter?) | ||
.map(&:counter_cache_column) | ||
counter_cache_columns.include?(c.name) |
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.
Seeing where this method is called as ultimately part of a loop, should we memoize the value?
Check the column is actually a counter cache column. Fixes #7346