Skip to content

Commit

Permalink
Also use Arel asc/desc when custom order is SqlLiteral (leikind#73)
Browse files Browse the repository at this point in the history
Fixes 'Dangerous query method (method whose arguments are used as raw SQL) called with non-attribute argument(s)' deprecation warning in Rails 5.2+
  • Loading branch information
kreintjes authored Jan 30, 2020
1 parent 4f9a8ec commit c7a9da2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Unreleased

* Fix bug in "Dangerous query methods" deprecation warning fix in custom order when using Arel.sql

## 4.1.0 (28 November, 2018)

* Add option `filter_control_options` to columns. Initial use is to pass in the options `start_year`, `end_year`, and `max_year_allowed` when using `rails_datetime_helper` - [#12](https://github.com/patricklindsay/wice_grid/pull/18)
Expand Down
2 changes: 1 addition & 1 deletion lib/wice_grid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def form_ar_options(opts = {}) #:nodoc:
else
@ar_options[:order] = arel_column_reference(@status[:order])
end
if @ar_options[:order].is_a?(Arel::Attributes::Attribute)
if @ar_options[:order].is_a?(Arel::Attributes::Attribute) || @ar_options[:order].is_a?(Arel::Nodes::SqlLiteral)
if @status[:order_direction] == 'desc'
@ar_options[:order] = @ar_options[:order].desc
else
Expand Down

0 comments on commit c7a9da2

Please sign in to comment.