Module: Bmg::Sql::SelectItem

Includes:
Expr
Defined in:
lib/bmg/sql/nodes/select_item.rb

Constant Summary

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, #flatten, #group_by?, #join?, #limit_or_offset?, #order_by?, #ordering, #set_operator?, #with_insert, #with_push, #with_update

Instance Method Details

#as_nameObject



22
23
24
# File 'lib/bmg/sql/nodes/select_item.rb', line 22

def as_name
  last.as_name
end

#is_computed?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/bmg/sql/nodes/select_item.rb', line 26

def is_computed?
  left.is_computed?
end

#leftObject



6
7
8
# File 'lib/bmg/sql/nodes/select_item.rb', line 6

def left
  self[1]
end

#qualifierObject



14
15
16
# File 'lib/bmg/sql/nodes/select_item.rb', line 14

def qualifier
  left.qualifier
end

#rightObject



10
11
12
# File 'lib/bmg/sql/nodes/select_item.rb', line 10

def right
  self[2]
end

#to_sql(buffer, dialect) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/bmg/sql/nodes/select_item.rb', line 30

def to_sql(buffer, dialect)
  self[1].to_sql(buffer, dialect)
  unless would_be_name == as_name
    buffer << SPACE << AS << SPACE
    last.to_sql(buffer, dialect)
  end
  buffer
end

#would_be_nameObject



18
19
20
# File 'lib/bmg/sql/nodes/select_item.rb', line 18

def would_be_name
  left.would_be_name
end