Class: Ronin::Code::SQL::Select
Instance Attribute Summary
Attributes inherited from Statement
#clauses
Instance Method Summary
collapse
Methods inherited from Statement
clause_order, clauses, #get_clause, #has_clause?, has_clause?
Methods inherited from Expr
#===, #in?, #not_in?
Constructor Details
#initialize(dialect, options = {}, &block) ⇒ Select
Returns a new instance of Select.
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/ronin/code/sql/select.rb', line 52
def initialize(dialect,options={},&block)
super(dialect,options)
if options[:distinct_rows]
self.distinct_rows!
end
if options[:all_rows]
self.all_rows!
end
unless options[:fields]
fields(all)
end
instance_eval(&block) if block
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Ronin::Code::SQL::Statement
Instance Method Details
#all_rows! ⇒ Object
70
71
72
73
|
# File 'lib/ronin/code/sql/select.rb', line 70
def all_rows!
@all_rows = true
return self
end
|
#all_rows? ⇒ Boolean
75
76
77
|
# File 'lib/ronin/code/sql/select.rb', line 75
def all_rows?
@all_rows == true
end
|
#distinct_rows! ⇒ Object
79
80
81
82
|
# File 'lib/ronin/code/sql/select.rb', line 79
def distinct_rows!
@distinct_rows = true
return self
end
|
#distinct_rows? ⇒ Boolean
84
85
86
|
# File 'lib/ronin/code/sql/select.rb', line 84
def distinct_rows?
@distinct_rows == true
end
|
#emit ⇒ Object
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/ronin/code/sql/select.rb', line 88
def emit
tokens = emit_token('SELECT')
if @distinct_rows
tokens += emit_token('DISTINCT')
elsif @all_rows
tokens += emit_token('ALL')
end
return tokens + super
end
|