class Sequel::SQL::OrderedExpression

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

Constants

INVERT_NULLS

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=OPTS) click to toggle source

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

:nulls

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

     # File lib/sequel/sql.rb
1676 def initialize(expression, descending = true, opts=OPTS)
1677   @expression = expression
1678   @descending = descending
1679   @nulls = opts[:nulls]
1680   freeze
1681 end

Public Instance Methods

asc() click to toggle source

Return a copy that is ordered ASC

     # File lib/sequel/sql.rb
1684 def asc
1685   OrderedExpression.new(@expression, false, :nulls=>@nulls)
1686 end
desc() click to toggle source

Return a copy that is ordered DESC

     # File lib/sequel/sql.rb
1689 def desc
1690   OrderedExpression.new(@expression, true, :nulls=>@nulls)
1691 end
invert() click to toggle source

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

     # File lib/sequel/sql.rb
1694 def invert
1695   OrderedExpression.new(@expression, !@descending, :nulls=>INVERT_NULLS.fetch(@nulls, @nulls))
1696 end