Class | Sequel::SQL::OrderedExpression
In: | lib/sequel/sql.rb
Parent: | Expression

Represents a column/expression to order the result set by.

### Methods

asc desc invert new

### Constants

INVERT_NULLS | = | {:first=>:last, :last=>:first}.freeze

### Attributes

descending | [R] | Whether the expression should order the result set in a descending manner
expression | [R] | The expression to order the result set by.
nulls | [R] | Whether to sort NULLS FIRST/LAST

### Public Class methods

new(expression, descending = true, opts={})

Set the expression and descending attributes to the given values. Options:

:nulls : | Can be :first/:last for NULLS FIRST/LAST.

[Source]

         # File lib/sequel/sql.rb, line 857
    857:       def initialize(expression, descending = true, opts={})
    858:         @expression, @descending, @nulls = expression, descending, opts[:nulls]
    859:       end

### Public Instance methods

asc()

Return a copy that is ordered ASC

[Source]

         # File lib/sequel/sql.rb, line 862
    862:       def asc
    863:         OrderedExpression.new(@expression, false, :nulls=>@nulls)
    864:       end

desc()

Return a copy that is ordered DESC

[Source]

         # File lib/sequel/sql.rb, line 867
    867:       def desc
    868:         OrderedExpression.new(@expression, true, :nulls=>@nulls)
    869:       end

invert()

Return an inverted expression, changing ASC to DESC and NULLS FIRST to NULLS LAST.

[Source]

         # File lib/sequel/sql.rb, line 872
    872:       def invert
    873:         OrderedExpression.new(@expression, !@descending, :nulls=>INVERT_NULLS.fetch(@nulls, @nulls))
    874:       end

[Validate]