Skip to content

Commit

Permalink
Also use Arel asc/desc when custom order is SqlLiteral
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 committed Jan 27, 2020
1 parent 4f9a8ec commit 5f6e0df
Showing 1 changed file with 1 addition and 1 deletion.
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 5f6e0df

Please sign in to comment.