Sha256: 71eb2c36ef67c34c50aea303819eb17806c4b6c8f24acf34d318f7e2ab7db878
Contents?: true
Size: 562 Bytes
Versions: 2
Compression:
Stored size: 562 Bytes
Contents
require 'pg_query' module HSQL # PgQuery uses Postgres' own parser to parse and then deparse each query. class Query < Struct.new(:ast) # Returns a list of queries found in the source SQL 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 # Show the parsed query as reconstructed SQL def to_s PgQuery::Deparse.from ast end alias_method :to_sql, :to_s end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hsql-0.4.0 | lib/hsql/query.rb |
hsql-0.3.8 | lib/hsql/query.rb |