Class: GoogleDataSource::DataSource::SqlParser

Inherits:
Object
  • Object
show all
Includes:
GoogleDataSource::DataSource::Sql::Parser
Defined in:
lib/google_data_source/sql_parser.rb

Constant Summary

Constants included from GoogleDataSource::DataSource::Sql::Parser

GoogleDataSource::DataSource::Sql::Parser::Comparators, GoogleDataSource::DataSource::Sql::Parser::MyKeywords, GoogleDataSource::DataSource::Sql::Parser::MyLexeme, GoogleDataSource::DataSource::Sql::Parser::MyLexer, GoogleDataSource::DataSource::Sql::Parser::MyOperators, GoogleDataSource::DataSource::Sql::Parser::QuotedName, GoogleDataSource::DataSource::Sql::Parser::StringLiteral, GoogleDataSource::DataSource::Sql::Parser::Variable

Class Method Summary collapse

Methods included from GoogleDataSource::DataSource::Sql::Parser

#assemble, #calculate_full_cases, #calculate_simple_cases, #comma, #ctor, #expression, #keyword, #list, #logical_operator, #make, #make_between, #make_between_clause, #make_comparison_predicate, #make_exists, #make_expression, #make_in, #make_in_relation, #make_not_between, #make_not_exists, #make_not_in, #make_not_in_relation, #make_predicate, #make_relation, #operator, operators, #paren, #predicate, #rctor, #relation, #word

Class Method Details

.parse(query) ⇒ Object

Parses a SQL query and returns the result



26
27
28
# File 'lib/google_data_source/sql_parser.rb', line 26

def parse(query)
  parser.parse(query)
end

.simple_parse(query) ⇒ Object

Parses a simple SQL query and return the result The where statement may only contain equality comparisons that are connected with ‘and’ Only a single ordering parameter is accepted Throws a SimpleSqlException if these conditions are not satisfied



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/google_data_source/sql_parser.rb', line 13

def simple_parse(query)
  result = parse(query)
  OpenStruct.new({
    :select => result.select.collect(&:to_s),
    :conditions => simple_where_parser(result.where),
    :orderby => simple_orderby_parser(result.orderby),
    :groupby => simple_groupby_parser(result.groupby),
    :limit => result.limit,
    :offset => result.offset
  })
end