Class Sequel::SQL::OrderedExpression
In: lib/sequel/extensions/eval_inspect.rb
lib/sequel/sql.rb
Parent: Object

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

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 1610
1610:       def initialize(expression, descending = true, opts=OPTS)
1611:         @expression = expression
1612:         @descending = descending
1613:         @nulls = opts[:nulls]
1614:         freeze
1615:       end

Public Instance methods

Return a copy that is ordered ASC

[Source]

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

Return a copy that is ordered DESC

[Source]

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

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

[Source]

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

[Validate]