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

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 911
911:       def initialize(expression, descending = true, opts={})
912:         @expression, @descending, @nulls = expression, descending, opts[:nulls]
913:       end

Public Instance methods

Return a copy that is ordered ASC

[Source]

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

Return a copy that is ordered DESC

[Source]

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

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

[Source]

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

[Validate]