Represents a column/expression to order the result set by.
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
new(expression, descending = true, opts=OPTS)
Set the expression and descending attributes to the given values. Options:
| :nulls |
Can be :first/:last for NULLS FIRST/LAST. |
[show source]
# File lib/sequel/sql.rb 1687 def initialize(expression, descending = true, opts=OPTS) 1688 @expression = expression 1689 @descending = descending 1690 @nulls = opts[:nulls] 1691 freeze 1692 end
Public Instance methods
asc()
Return a copy that is ordered ASC
[show source]
# File lib/sequel/sql.rb 1695 def asc 1696 OrderedExpression.new(@expression, false, :nulls=>@nulls) 1697 end
desc()
Return a copy that is ordered DESC
[show source]
# File lib/sequel/sql.rb 1700 def desc 1701 OrderedExpression.new(@expression, true, :nulls=>@nulls) 1702 end
invert()
Return an inverted expression, changing ASC to DESC and NULLS FIRST to NULLS LAST.
[show source]
# File lib/sequel/sql.rb 1705 def invert 1706 OrderedExpression.new(@expression, !@descending, :nulls=>INVERT_NULLS.fetch(@nulls, @nulls)) 1707 end