-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: view -> query & test helpers
- Loading branch information
1 parent
3142545
commit 66327e6
Showing
4 changed files
with
28 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module SqlTools | ||
class View | ||
class Query | ||
attr_accessor :select, :from | ||
attr_reader :common_table_expressions | ||
|
||
|
12 changes: 6 additions & 6 deletions
12
lib/sql_tools/view_visitor.rb → lib/sql_tools/query_visitor.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
module SqlTools | ||
class ViewVisitor < TreeStand::Visitor | ||
attr_reader :view | ||
class QueryVisitor < TreeStand::Visitor | ||
attr_reader :query | ||
|
||
def initialize(node) | ||
super(node) | ||
@ctes = {} | ||
@view = View.new | ||
@query = Query.new | ||
end | ||
|
||
def on_cte(node) | ||
cte = CommonTableExpression.new(node) | ||
@view.common_table_expressions[cte.name] = cte | ||
@query.common_table_expressions[cte.name] = cte | ||
end | ||
|
||
def on_select(node) | ||
@view.select = node | ||
@query.select = node | ||
end | ||
|
||
def on_from(node) | ||
@view.from = node | ||
@query.from = node | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters