Flowdock
method

reverse_sql_order

Importance_0
v3.1.0 - Show latest stable - 0 notes - Class: ActiveRecord::QueryMethods
reverse_sql_order(order_query) private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/relation/query_methods.rb, line 305
    def reverse_sql_order(order_query)
      order_query = ["#{quoted_table_name}.#{quoted_primary_key} ASC"] if order_query.empty?

      order_query.map do |o|
        case o
        when Arel::Nodes::Ascending, Arel::Nodes::Descending
          o.reverse
        when String, Symbol
          o.to_s.split(',').collect do |s|
            s.gsub!(/\sasc\Z/, ' DESC') || s.gsub!(/\sdesc\Z/, ' ASC') || s.concat(' DESC')
          end
        else
          o
        end
      end.flatten
    end
Register or log in to add new notes.