class Seaquel::StatementGatherer
Visits a statement AST
and issues a statement.
Attributes
current_join[R]
Public Class Methods
new(statement, quoter)
click to toggle source
# File lib/seaquel/statement_gatherer.rb, line 9 def initialize statement, quoter @statement = statement @quoter = quoter @current_join = nil end
Public Instance Methods
visit_delete(parent)
click to toggle source
# File lib/seaquel/statement_gatherer.rb, line 101 def visit_delete parent continue(parent) s.set_type(:delete) end
visit_fields(parent, fields)
click to toggle source
# File lib/seaquel/statement_gatherer.rb, line 95 def visit_fields parent, fields continue(parent) s.fields.concat(fields) end
visit_from(parent, *args)
click to toggle source
# File lib/seaquel/statement_gatherer.rb, line 17 def visit_from parent, *args s.from.concat(args) continue(parent) end
visit_group_by(parent, list)
click to toggle source
# File lib/seaquel/statement_gatherer.rb, line 69 def visit_group_by parent, list continue(parent) s.group_by.replace(list) end
visit_having(parent, exps)
click to toggle source
# File lib/seaquel/statement_gatherer.rb, line 74 def visit_having parent, exps continue(parent) s.having.concat(*exps) end
visit_insert(parent)
click to toggle source
# File lib/seaquel/statement_gatherer.rb, line 80 def visit_insert parent continue(parent) s.set_type(:insert) end
visit_into(parent, table)
click to toggle source
# File lib/seaquel/statement_gatherer.rb, line 85 def visit_into parent, table continue(parent) s.set_target(table) end
visit_join(parent, tables)
click to toggle source
# File lib/seaquel/statement_gatherer.rb, line 55 def visit_join parent, tables continue(parent) @current_join = s.join(tables) end
visit_limit(parent, n)
click to toggle source
# File lib/seaquel/statement_gatherer.rb, line 112 def visit_limit parent, n continue(parent) s.set_limit(n) end
visit_offset(parent, n)
click to toggle source
# File lib/seaquel/statement_gatherer.rb, line 107 def visit_offset parent, n continue(parent) s.set_offset(n) end
visit_on(parent, exps)
click to toggle source
# File lib/seaquel/statement_gatherer.rb, line 60 def visit_on(parent, exps) continue(parent) raise InvalidExpression, ".on without a .join encoutered" \ unless current_join current_join.on(*exps) end
visit_order_by(parent, list)
click to toggle source
# File lib/seaquel/statement_gatherer.rb, line 32 def visit_order_by parent, list continue(parent) s.order_by.replace(list) end
visit_project(parent, fields)
click to toggle source
# File lib/seaquel/statement_gatherer.rb, line 25 def visit_project parent, fields continue(parent) # Since the tree is processed in lifo order, we need to only apply the # very last project. s.project.replace(fields) end
visit_select(parent)
click to toggle source
# File lib/seaquel/statement_gatherer.rb, line 22 def visit_select parent continue(parent) end
visit_set(parent, assign_list)
click to toggle source
# File lib/seaquel/statement_gatherer.rb, line 49 def visit_set parent, assign_list continue(parent) s.set.concat(assign_list) end
visit_update(parent, table)
click to toggle source
# File lib/seaquel/statement_gatherer.rb, line 43 def visit_update parent, table continue(parent) s.set_type(:update) s.set_target(table) end
visit_values(parent, values)
click to toggle source
# File lib/seaquel/statement_gatherer.rb, line 90 def visit_values parent, values continue(parent) s.values << AST::List.new(values) end
visit_where(parent, expression)
click to toggle source
# File lib/seaquel/statement_gatherer.rb, line 37 def visit_where parent, expression continue(parent) s.where.concat(expression) end
Private Instance Methods
continue(node)
click to toggle source
A shorthand for saying that node needs to be visited.
# File lib/seaquel/statement_gatherer.rb, line 121 def continue node node.visit(self) if node end
s()
click to toggle source
A short-cut for the code in here.
# File lib/seaquel/statement_gatherer.rb, line 126 def s @statement end