Represents a column/expression to order the result set by.
Whether the expression should order the result set in a descending manner
The expression to order the result set by.
Whether to sort NULLS FIRST/LAST
Set the expression and descending attributes to the given values. Options:
Can be :first/:last for NULLS FIRST/LAST.
# File lib/sequel/sql.rb, line 1525 def initialize(expression, descending = true, opts=OPTS) @expression, @descending, @nulls = expression, descending, opts[:nulls] end
Return a copy that is ordered ASC
# File lib/sequel/sql.rb, line 1530 def asc OrderedExpression.new(@expression, false, :nulls=>@nulls) end
Return a copy that is ordered DESC
# File lib/sequel/sql.rb, line 1535 def desc OrderedExpression.new(@expression, true, :nulls=>@nulls) end
Return an inverted expression, changing ASC to DESC and NULLS FIRST to NULLS LAST.
# File lib/sequel/sql.rb, line 1540 def invert OrderedExpression.new(@expression, !@descending, :nulls=>INVERT_NULLS.fetch(@nulls, @nulls)) end
OrderedExpression's initializer takes the :nulls information inside a hash, so if a NULL order was given, include a hash with that information.
# File lib/sequel/extensions/eval_inspect.rb, line 168 def inspect_args if nulls [:expression, :descending, :opts_hash] else [:expression, :descending] end end
A hash of null information suitable for passing to the initializer.
# File lib/sequel/extensions/eval_inspect.rb, line 177 def opts_hash {:nulls=>nulls} end