Module: Ronin::Code::SQL::Clauses
Overview
Methods for creating common SQL Clauses.
Instance Method Summary collapse
-
#clause(keyword, argument = nil) {|(clause)| ... } ⇒ self
Appends an arbitrary clause.
-
#clauses ⇒ Array<Clause>
The defined clauses of the statement.
-
#default_values ⇒ self
Appends a
DEFAULT VALUES
clause. -
#from(table = nil, &block) ⇒ self
Appends a
FROM
clause. -
#full_join(table = nil, &block) ⇒ self
Appends a
FULL JOIN
clause. -
#group_by(*columns, &block) ⇒ self
Appends a
GROUP BY
clause. -
#having(&block) ⇒ self
Appends a
HAVING
clause. -
#indexed_by(name, &block) ⇒ self
Appends a
INDEXED BY
clause. -
#inner_join(table = nil, &block) ⇒ self
Appends a
INNER JOIN
clause. -
#into(table = nil, &block) ⇒ self
Appends an
INTO
clause. -
#join(table = nil, &block) ⇒ self
Appends a
JOIN
clause. -
#left_join(table = nil, &block) ⇒ self
Appends a
LEFT JOIN
clause. -
#limit(value, &block) ⇒ self
Appends a
LIMIT
clause. -
#not_indexed ⇒ self
Appends a
NOT INDEXED
clause. -
#offset(value, &block) ⇒ self
Appends a
OFFSET
clause. -
#on(&block) ⇒ self
Appends a
ON
clause. -
#order_by(*columns, &block) ⇒ self
Appends a
ORDER BY
clause. -
#right_join(table = nil, &block) ⇒ self
Appends a
RIGHT JOIN
clause. -
#set(values = {}) ⇒ self
Appends a
SET
clause. -
#top(value, &block) ⇒ self
Appends a
TOP
clause. -
#union(&block) ⇒ self
Appends a
UNION
clause. -
#union_all(&block) ⇒ self
Appends a
UNION ALL
clause. -
#values(*values) ⇒ self
Appends a
VALUES
clause. -
#where(&block) ⇒ self
Appends a
WHERE
clause.
Instance Method Details
#clause(keyword, argument = nil) {|(clause)| ... } ⇒ self
Appends an arbitrary clause.
58 59 60 61 |
# File 'lib/ronin/code/sql/clauses.rb', line 58 def clause(keyword,argument=nil,&block) clauses << Clause.new(keyword,argument,&block) return self end |
#clauses ⇒ Array<Clause>
The defined clauses of the statement.
36 37 38 |
# File 'lib/ronin/code/sql/clauses.rb', line 36 def clauses @clauses ||= [] end |
#default_values ⇒ self
Appends a DEFAULT VALUES
clause.
273 274 275 |
# File 'lib/ronin/code/sql/clauses.rb', line 273 def default_values clause([:DEFAULT, :VALUES]) end |
#from(table = nil, &block) ⇒ self
Appends a FROM
clause.
71 72 73 |
# File 'lib/ronin/code/sql/clauses.rb', line 71 def from(table=nil,&block) clause(:FROM,table,&block) end |
#full_join(table = nil, &block) ⇒ self
Appends a FULL JOIN
clause.
152 153 154 |
# File 'lib/ronin/code/sql/clauses.rb', line 152 def full_join(table=nil,&block) clause([:FULL, :JOIN],table,&block) end |
#group_by(*columns, &block) ⇒ self
Appends a GROUP BY
clause.
193 194 195 |
# File 'lib/ronin/code/sql/clauses.rb', line 193 def group_by(*columns,&block) clause([:GROUP, :BY],columns,&block) end |
#having(&block) ⇒ self
Appends a HAVING
clause.
216 217 218 |
# File 'lib/ronin/code/sql/clauses.rb', line 216 def having(&block) clause(:HAVING,&block) end |
#indexed_by(name, &block) ⇒ self
Appends a INDEXED BY
clause.
297 298 299 |
# File 'lib/ronin/code/sql/clauses.rb', line 297 def indexed_by(name,&block) clause([:INDEXED, :BY],name,&block) end |
#inner_join(table = nil, &block) ⇒ self
Appends a INNER JOIN
clause.
116 117 118 |
# File 'lib/ronin/code/sql/clauses.rb', line 116 def inner_join(table=nil,&block) clause([:INNER, :JOIN],table,&block) end |
#into(table = nil, &block) ⇒ self
Appends an INTO
clause.
83 84 85 |
# File 'lib/ronin/code/sql/clauses.rb', line 83 def into(table=nil,&block) clause(:INTO,table,&block) end |
#join(table = nil, &block) ⇒ self
Appends a JOIN
clause.
104 105 106 |
# File 'lib/ronin/code/sql/clauses.rb', line 104 def join(table=nil,&block) clause(:JOIN,table,&block) end |
#left_join(table = nil, &block) ⇒ self
Appends a LEFT JOIN
clause.
128 129 130 |
# File 'lib/ronin/code/sql/clauses.rb', line 128 def left_join(table=nil,&block) clause([:LEFT, :JOIN],table,&block) end |
#limit(value, &block) ⇒ self
Appends a LIMIT
clause.
228 229 230 |
# File 'lib/ronin/code/sql/clauses.rb', line 228 def limit(value,&block) clause(:LIMIT,value,&block) end |
#not_indexed ⇒ self
Appends a NOT INDEXED
clause.
306 307 308 |
# File 'lib/ronin/code/sql/clauses.rb', line 306 def not_indexed clause([:NOT, :INDEXED]) end |
#offset(value, &block) ⇒ self
Appends a OFFSET
clause.
240 241 242 |
# File 'lib/ronin/code/sql/clauses.rb', line 240 def offset(value,&block) clause(:OFFSET,value,&block) end |
#on(&block) ⇒ self
Appends a ON
clause.
161 162 163 |
# File 'lib/ronin/code/sql/clauses.rb', line 161 def on(&block) clause(:ON,&block) end |
#order_by(*columns, &block) ⇒ self
Appends a ORDER BY
clause.
207 208 209 |
# File 'lib/ronin/code/sql/clauses.rb', line 207 def order_by(*columns,&block) clause([:ORDER, :BY],columns,&block) end |
#right_join(table = nil, &block) ⇒ self
Appends a RIGHT JOIN
clause.
140 141 142 |
# File 'lib/ronin/code/sql/clauses.rb', line 140 def right_join(table=nil,&block) clause([:RIGHT, :JOIN],table,&block) end |
#set(values = {}) ⇒ self
Appends a SET
clause.
285 286 287 |
# File 'lib/ronin/code/sql/clauses.rb', line 285 def set(values={}) clause(:SET,values) end |
#top(value, &block) ⇒ self
Appends a TOP
clause.
252 253 254 |
# File 'lib/ronin/code/sql/clauses.rb', line 252 def top(value,&block) clause(:TOP,value,&block) end |
#union(&block) ⇒ self
Appends a UNION
clause.
170 171 172 |
# File 'lib/ronin/code/sql/clauses.rb', line 170 def union(&block) clause(:UNION,&block) end |
#union_all(&block) ⇒ self
Appends a UNION ALL
clause.
181 182 183 |
# File 'lib/ronin/code/sql/clauses.rb', line 181 def union_all(&block) clause([:UNION, :ALL],&block) end |
#values(*values) ⇒ self
Appends a VALUES
clause.
264 265 266 |
# File 'lib/ronin/code/sql/clauses.rb', line 264 def values(*values) clause(:VALUES,values) end |
#where(&block) ⇒ self
Appends a WHERE
clause.
92 93 94 |
# File 'lib/ronin/code/sql/clauses.rb', line 92 def where(&block) clause(:WHERE,&block) end |