Module: SqlTools
- Defined in:
- lib/sql_tools.rb,
lib/sql_tools/index.rb,
lib/sql_tools/query.rb,
lib/sql_tools/schema.rb,
lib/sql_tools/version.rb,
lib/sql_tools/relation.rb,
lib/sql_tools/left_join.rb,
lib/sql_tools/predicate.rb,
lib/sql_tools/selection.rb,
lib/sql_tools/constraint.rb,
lib/sql_tools/inner_join.rb,
lib/sql_tools/query_visitor.rb,
lib/sql_tools/schema_visitor.rb,
lib/sql_tools/predicate_filter.rb,
lib/sql_tools/column_definition.rb,
lib/sql_tools/predicate_visitor.rb,
lib/sql_tools/common_table_expression.rb
Defined Under Namespace
Modules: Selection
Classes: ColumnDefinition, CommonTableExpression, Constraint, Error, Index, Predicate, PredicateFilter, PredicateVisitor, Query, QueryVisitor, Relation, Schema, SchemaVisitor
Constant Summary
collapse
- Table =
Data.define(:name, :alias)
- Column =
Data.define(:table, :name) do
def to_s = "#{table.name}.#{name}"
def inspect = to_s
end
- VERSION =
"0.2.2"
- LeftJoin =
Data.define(:object, :predicate)
- InnerJoin =
Data.define(:object, :predicate)
Class Method Summary
collapse
Class Method Details
.parser ⇒ Object
18
|
# File 'lib/sql_tools.rb', line 18
def parser = @parser ||= TreeStand::Parser.new("sql")
|
.query_from_sql(sql) ⇒ Object
15
|
# File 'lib/sql_tools.rb', line 15
def query_from_sql(sql) = query_from_tree(tree_from_sql(sql))
|
.query_from_tree(tree) ⇒ Object
16
|
# File 'lib/sql_tools.rb', line 16
def query_from_tree(tree) = SqlTools::QueryVisitor.new(tree.root_node).visit.query
|
.schema_from_sql(sql) ⇒ Object
13
|
# File 'lib/sql_tools.rb', line 13
def schema_from_sql(sql) = schema_from_tree(tree_from_sql(sql))
|
.schema_from_tree(tree) ⇒ Object
14
|
# File 'lib/sql_tools.rb', line 14
def schema_from_tree(tree) = SqlTools::SchemaVisitor.new(tree.root_node).visit.schema
|
.tree_from_sql(sql) ⇒ Object
17
|
# File 'lib/sql_tools.rb', line 17
def tree_from_sql(sql) = parser.parse_string(sql)
|