class Sequel::SQL::OrderedExpression

  1. lib/sequel/sql.rb
Superclass: Expression

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


Public Class

  1. new

Public Instance

  1. asc
  2. desc
  3. descending
  4. expression
  5. invert
  6. nulls


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


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)

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


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

[show source]
     # File lib/sequel/sql.rb
1673 def initialize(expression, descending = true, opts=OPTS)
1674   @expression = expression
1675   @descending = descending
1676   @nulls = opts[:nulls]
1677   freeze
1678 end

Public Instance methods


Return a copy that is ordered ASC

[show source]
     # File lib/sequel/sql.rb
1681 def asc
1682, false, :nulls=>@nulls)
1683 end

Return a copy that is ordered DESC

[show source]
     # File lib/sequel/sql.rb
1686 def desc
1687, true, :nulls=>@nulls)
1688 end

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

[show source]
     # File lib/sequel/sql.rb
1691 def invert
1692, !@descending, :nulls=>INVERT_NULLS.fetch(@nulls, @nulls))
1693 end