Class: SqlTools::QueryVisitor
- Inherits:
-
TreeStand::Visitor
- Object
- TreeStand::Visitor
- SqlTools::QueryVisitor
- Defined in:
- lib/sql_tools/query_visitor.rb
Instance Attribute Summary collapse
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Instance Method Summary collapse
-
#initialize(node) ⇒ QueryVisitor
constructor
A new instance of QueryVisitor.
- #on_cte(node) ⇒ Object
- #on_from(node) ⇒ Object
- #on_join(node) ⇒ Object
- #on_select(node) ⇒ Object
Constructor Details
#initialize(node) ⇒ QueryVisitor
Returns a new instance of QueryVisitor.
5 6 7 8 9 |
# File 'lib/sql_tools/query_visitor.rb', line 5 def initialize(node) super(node) @ctes = {} @query = Query.new end |
Instance Attribute Details
#query ⇒ Object (readonly)
Returns the value of attribute query.
3 4 5 |
# File 'lib/sql_tools/query_visitor.rb', line 3 def query @query end |
Instance Method Details
#on_cte(node) ⇒ Object
11 12 13 14 |
# File 'lib/sql_tools/query_visitor.rb', line 11 def on_cte(node) cte = CommonTableExpression.new(node) @query.common_table_expressions[cte.name] = cte end |
#on_from(node) ⇒ Object
20 21 22 |
# File 'lib/sql_tools/query_visitor.rb', line 20 def on_from(node) @query.from = node end |
#on_join(node) ⇒ Object
24 25 26 |
# File 'lib/sql_tools/query_visitor.rb', line 24 def on_join(node) @query.join_nodes << node end |
#on_select(node) ⇒ Object
16 17 18 |
# File 'lib/sql_tools/query_visitor.rb', line 16 def on_select(node) @query.select = node end |