Class: HSQL::Query
- Inherits:
-
Struct
- Object
- Struct
- HSQL::Query
- Defined in:
- lib/hsql/query.rb
Overview
PgQuery uses Postgres’ own parser to parse and then deparse each query.
Instance Attribute Summary collapse
-
#ast ⇒ Object
Returns the value of attribute ast.
Class Method Summary collapse
-
.parse(source) ⇒ Object
Returns a list of queries found in the source SQL.
Instance Method Summary collapse
-
#to_s ⇒ Object
(also: #to_sql)
Show the parsed query as reconstructed SQL.
Instance Attribute Details
#ast ⇒ Object
Returns the value of attribute ast
4 5 6 |
# File 'lib/hsql/query.rb', line 4 def ast @ast end |
Class Method Details
.parse(source) ⇒ Object
Returns a list of queries found in the source SQL
6 7 8 9 10 11 12 |
# File 'lib/hsql/query.rb', line 6 def self.parse(source) # Splits on semicolons at the end of the line, eliding any comment that # might be there. PgQuery.parse(source).parsetree.map do |ast| Query.new(ast) end end |
Instance Method Details
#to_s ⇒ Object Also known as: to_sql
Show the parsed query as reconstructed SQL
15 16 17 |
# File 'lib/hsql/query.rb', line 15 def to_s PgQuery::Deparse.from ast end |