Class: Sequel::SQL::OrderedExpression

Inherits:
SpecificExpression show all
Defined in:
lib/sequel_core/sql.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Expression

#lit

Constructor Details

#initialize(expression, descending = true) ⇒ OrderedExpression

Set the expression and descending attributes to the given values.



681
682
683
# File 'lib/sequel_core/sql.rb', line 681

def initialize(expression, descending = true)
  @expression, @descending = expression, descending
end

Instance Attribute Details

#descendingObject (readonly)

Whether the expression should order the result set in a descending manner



678
679
680
# File 'lib/sequel_core/sql.rb', line 678

def descending
  @descending
end

#expressionObject (readonly)

The expression to order the result set by.



675
676
677
# File 'lib/sequel_core/sql.rb', line 675

def expression
  @expression
end

Instance Method Details

#to_s(ds) ⇒ Object

Delegate the creation of the resulting SQL to the given dataset, since it may be database dependent.



687
688
689
# File 'lib/sequel_core/sql.rb', line 687

def to_s(ds)
  ds.ordered_expression_sql(self)
end