Module: Bmg::Sql::SelectExp
- Includes:
- Expr
- Defined in:
- lib/bmg/sql/nodes/select_exp.rb
Constant Summary
collapse
- SELECT_DISTINCT =
"SELECT DISTINCT".freeze
- SELECT =
"SELECT".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, #flatten, #group_by?, #limit_or_offset?, #order_by?, #ordering, #set_operator?, #with_insert, #with_push, #with_update
Instance Method Details
#all? ⇒ Boolean
26
27
28
|
# File 'lib/bmg/sql/nodes/select_exp.rb', line 26
def all?
set_quantifier.all?
end
|
#complex_clause? ⇒ Boolean
42
43
44
|
# File 'lib/bmg/sql/nodes/select_exp.rb', line 42
def complex_clause?
where_clause or order_by_clause or limit_clause or offset_clause
end
|
#desaliaser(*args, &bl) ⇒ Object
90
91
92
|
# File 'lib/bmg/sql/nodes/select_exp.rb', line 90
def desaliaser(*args, &bl)
select_list.desaliaser(*args, &bl)
end
|
#distinct? ⇒ Boolean
22
23
24
|
# File 'lib/bmg/sql/nodes/select_exp.rb', line 22
def distinct?
set_quantifier.distinct?
end
|
#from_clause ⇒ Object
66
67
68
|
# File 'lib/bmg/sql/nodes/select_exp.rb', line 66
def from_clause
find_child(:from_clause)
end
|
#group_by_clause ⇒ Object
74
75
76
|
# File 'lib/bmg/sql/nodes/select_exp.rb', line 74
def group_by_clause
find_child(:group_by_clause)
end
|
#has_computed_attributes? ⇒ Boolean
30
31
32
|
# File 'lib/bmg/sql/nodes/select_exp.rb', line 30
def has_computed_attributes?
select_list.has_computed_attributes?
end
|
#is_select_star? ⇒ Boolean
54
55
56
|
# File 'lib/bmg/sql/nodes/select_exp.rb', line 54
def is_select_star?
self[2].first == :select_star
end
|
#is_table_dee? ⇒ Boolean
18
19
20
|
# File 'lib/bmg/sql/nodes/select_exp.rb', line 18
def is_table_dee?
from_clause.nil? && select_list.is_table_dee?
end
|
#join? ⇒ Boolean
34
35
36
|
# File 'lib/bmg/sql/nodes/select_exp.rb', line 34
def join?
from_clause && from_clause.join?
end
|
#limit_clause ⇒ Object
82
83
84
|
# File 'lib/bmg/sql/nodes/select_exp.rb', line 82
def limit_clause
find_child(:limit_clause)
end
|
#offset_clause ⇒ Object
86
87
88
|
# File 'lib/bmg/sql/nodes/select_exp.rb', line 86
def offset_clause
find_child(:offset_clause)
end
|
#order_by_clause ⇒ Object
78
79
80
|
# File 'lib/bmg/sql/nodes/select_exp.rb', line 78
def order_by_clause
find_child(:order_by_clause)
end
|
#predicate ⇒ Object
62
63
64
|
# File 'lib/bmg/sql/nodes/select_exp.rb', line 62
def predicate
where_clause && where_clause.predicate
end
|
#select_exp ⇒ Object
46
47
48
|
# File 'lib/bmg/sql/nodes/select_exp.rb', line 46
def select_exp
self
end
|
#select_list ⇒ Object
50
51
52
|
# File 'lib/bmg/sql/nodes/select_exp.rb', line 50
def select_list
self[2]
end
|
#set_quantifier ⇒ Object
10
11
12
|
# File 'lib/bmg/sql/nodes/select_exp.rb', line 10
def set_quantifier
self[1]
end
|
#should_be_reused? ⇒ Boolean
38
39
40
|
# File 'lib/bmg/sql/nodes/select_exp.rb', line 38
def should_be_reused?
join? or distinct? or complex_clause?
end
|
#table_spec ⇒ Object
70
71
72
|
# File 'lib/bmg/sql/nodes/select_exp.rb', line 70
def table_spec
from_clause.table_spec
end
|
#to_attr_list ⇒ Object
96
97
98
|
# File 'lib/bmg/sql/nodes/select_exp.rb', line 96
def to_attr_list
select_list.to_attr_list
end
|
#to_sql(buffer, dialect, parenthesize = !buffer.empty?)) ⇒ Object
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/bmg/sql/nodes/select_exp.rb', line 102
def to_sql(buffer, dialect, parenthesize = !buffer.empty?)
if parenthesize
sql_parenthesized(buffer){|b| to_sql(b, dialect, false) }
else
buffer << (distinct? ? SELECT_DISTINCT : SELECT)
each_child(1) do |elm,i|
buffer << SPACE
elm.to_sql(buffer, dialect)
end
buffer
end
end
|
#where_clause ⇒ Object
58
59
60
|
# File 'lib/bmg/sql/nodes/select_exp.rb', line 58
def where_clause
find_child(:where_clause)
end
|
#with_exp? ⇒ Boolean
14
15
16
|
# File 'lib/bmg/sql/nodes/select_exp.rb', line 14
def with_exp?
false
end
|