1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/lib/arel/nodes/ordering.rb
Kevin Deisz 4a13f8ad4f
Properly support reverse_order on relations with nulls_first or nulls_last calls
If you're using the `nulls_first` or `nulls_last` functionality with an explicit ordering, then previously it wasn't properly handling calls to `#reverse` (called through `reverse_order`). This commit changes the behavior to match what would be expected.
2020-09-08 11:20:46 -04:00

27 lines
448 B
Ruby

# frozen_string_literal: true
module Arel # :nodoc: all
module Nodes
class Ordering < Unary
def nulls_first
NullsFirst.new(self)
end
def nulls_last
NullsLast.new(self)
end
end
class NullsFirst < Ordering
def reverse
NullsLast.new(expr.reverse)
end
end
class NullsLast < Ordering
def reverse
NullsFirst.new(expr.reverse)
end
end
end
end