Module: Alf::Sql::OrderByClause

Includes:
Expr
Defined in:
lib/alf/sql/nodes/order_by_clause.rb

Constant Summary collapse

ORDER_BY =
"ORDER BY".freeze

Constants included from Expr

Expr::AND, Expr::AS, Expr::COMMA, Expr::DOT, Expr::EQUAL, Expr::EXISTS, Expr::FALSE, Expr::GREATER, Expr::GREATER_OR_EQUAL, Expr::IN, Expr::LEFT_PARENTHESE, Expr::LESS, Expr::LESS_OR_EQUAL, Expr::NOT, Expr::NOT_EQUAL, Expr::OR, Expr::QUOTE, Expr::RIGHT_PARENTHESE, Expr::SPACE, Expr::TRUE

Instance Method Summary collapse

Methods included from Expr

#each_child, #join?, #limit_or_offset?, #ordering, #set_operator?, #with_insert, #with_push, #with_update

Instance Method Details

#to_orderingObject



8
9
10
11
12
# File 'lib/alf/sql/nodes/order_by_clause.rb', line 8

def to_ordering
  @ordering ||= Ordering.new(sexpr_body.map{|x|
    [x.as_name, x.direction]
  })
end

#to_sql(buffer = "") ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/alf/sql/nodes/order_by_clause.rb', line 14

def to_sql(buffer = "")
  buffer << ORDER_BY << SPACE
  each_child do |item,index|
    buffer << COMMA << SPACE unless index == 0
    item.to_sql(buffer)
  end
  buffer
end