geokit / geokit-rails

Official Geokit plugin for Rails/ActiveRecord. Provides location-based goodness for your Rails app. Requires the Geokit gem.
MIT License
1.57k stars 245 forks source link

Fix unsafe raw SQL warning #134

Closed flackou closed 6 years ago

flackou commented 6 years ago

Starting from Rails 5.2, there's a deprecation warning on using raw SQL fragments in some AR methods, including order, cf Rails 5.2 changelog :

Require raw SQL fragments to be explicitly marked when used in relation query methods.

The warning precises :

Non-attribute arguments will be disallowed in Rails 6.0

We just need to wrap the SQL in Arel.sql(...) to remove the warning. Tests config is also fixed for Rails >= 4 (fixing #129).

coveralls commented 6 years ago

Coverage Status

Coverage increased (+35.6%) to 84.364% when pulling f69b4091a680beb453136e44888caa3bab20e474 on flackou:fix_unsafe_raw_sql_warning into 9e5251afb76f14a5a2cd975023f0a0fab1e0cc80 on geokit:master.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+35.6%) to 84.364% when pulling 6448e9a0ef5cb72b1190ebfa175d7aba380ab6b8 on flackou:fix_unsafe_raw_sql_warning into 9e5251afb76f14a5a2cd975023f0a0fab1e0cc80 on geokit:master.

mnoack commented 6 years ago

Thanks for the PR @flackou

nholden commented 6 years ago

Thanks so much for this one, @flackou and @mnoack!

I'd love to see a new release of the geokit-rails gem with this included so that we can silence the deprecation warning in our Rails 5.2 apps without needing to point our Gemfiles at master. Let me know if there's anything I can do to help out with that.

mnoack commented 6 years ago

@nholden @flackou - I've just released a gem for the latest code. I've also added ruby 2.4/rails 5 to the travis test suite.

nholden commented 6 years ago

Thanks so much, @mnoack! Works great. 🎉