-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Extract methods assert_queries
and assert_no_queries
#42465
Conversation
Can we move this to |
Both methods are defined in multiple parts of the framework. It would be useful to put them in a proper place, so that repetition is avoided. I chose the implementation from `ActiveRecord` because it's a bit more complete with the `SQLCounter` class, and also because other parts depend on it.
e8da0a5
to
f644f7d
Compare
@pixeltrix Makes sense. I pushed new changes to address that. |
@ricardotk002 thanks for the quick turnaround on the changes 👍🏻 |
This is exposing those helpers to applications. We removed them years ago. Even though this is adding as private API, I think it would be better to not expose this on |
I agree that it probably shouldn't be exposed to the public. Still, I think there's a necessity for verifying the absence of N+1 queries in some parts of the framework (ActiveStorage, ActionText, etc); plus the implementation for |
I think we should wait this duplication become a pain before trying to extract. I'm fine with copying parts of the implementation for all the places that need them. At this points this is already in all frameworks that need it already. |
The reason I suggested extracting it was that it was copied as part of #40842 so it seemed like a good point to do it with it being in three places but it's not a hill I'm going to die on if people feel strongly the other way 🙃 |
Summary
Inspired by https://github.com/rails/rails/pull/40842/files#r650377037
Both methods are defined in multiple parts of the framework. It would
be useful to put them in a proper place, so that repetition is
avoided.
I chose the implementation from
ActiveRecord
because it's a bit morecomplete with the
SQLCounter
class, and also because other partsdepend on it.