-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Prevent dangerous query method on #order_by_id #1786
Prevent dangerous query method on #order_by_id #1786
Conversation
Thanks! Can you think of a way we can test this change? Running the specs currently doesn't throw this warning and ideally I'd like to be able to see the warning, apply the (tiny!) fix and then see it go away again. |
I will try to recreate the warning and get back to you |
@nickcharlton I spent the last couple days trying to recreate the warning in my forked repo but haven't had any luck. However, we recently migrated the app where I originally ran into this deprecation warning to rails 6 and we're not seeing the warning anymore. I did some digging into the rails code base and found this but still unsure why I am not seeing the deprecation warning anymore. |
Had a look at what's possible. How about adding the following to it "sorts by count on a has_many association" do
create_list(:order, 2, customer: create(:customer, name: "Ade"))
create_list(:order, 3, customer: create(:customer, name: "Ben"))
create_list(:order, 1, customer: create(:customer, name: "Cam"))
visit admin_customers_path
click_on "Orders"
expect(page).to have_content(/Cam.*1 order.*Ade.*2 orders.*Ben.*3 orders/)
click_on "Orders"
expect(page).to have_content(/Ben.*3 orders.*Ade.*2 orders.*Cam.*1 order/)
end Running this with Appraisal gemfile for Rails 5.2 will trigger the warning on master:
On your branch, the warning will not appear. |
@pablobm Thanks for this, I was actually able to recreate the deprecation warning on my branch by adding this test, temporarily removing |
Updated PR message with new changes |
- Checks sorting by has_many association
c4dba8a
to
ff9893c
Compare
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.
This looks good to me 👍
What does this PR do?
Arel.sql()
to#order_by_id
in/lib/order.rb
to prevent deprecation warning for dangerous query method.has_many
associationWhere should the reviewer start?
/lib/order.rb
How should this be manually tested?
Arel.sql()
from#order_by_id
bundle exec appraisal rails52 rspec spec/features/index_page_spec.rb
What are the relevant tickets?
#1758
Questions: