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 1116
    def reverse_sql_order(order_query)
      if order_query.empty?
        return [arel_attribute(primary_key).desc] if primary_key
        raise IrreversibleOrderError,
          "Relation has no current order and table has no primary key to be used as default order"
      end

      order_query.flat_map do |o|
        case o
        when Arel::Attribute
          o.desc
        when Arel::Nodes::Ordering
          o.reverse
        when String
          if does_not_support_reverse?(o)
            raise IrreversibleOrderError, "Order #{o.inspect} can not be reversed automatically"
          end
          o.split(',').map! do |s|
            s.strip!
            s.gsub!(/\sasc\Z/, ' DESC') || s.gsub!(/\sdesc\Z/, ' ASC') || s.concat(' DESC')
          end
        else
          o
        end
      end
    end
Register or log in to add new notes.