Sha256: 38a9b8bcf90873e05fcf64042044f626c4c5ee1ae282a2b6a87f826649120751
Contents?: true
Size: 556 Bytes
Versions: 8
Compression:
Stored size: 556 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 ast end alias_method :to_sql, :to_s end end
Version data entries
8 entries across 8 versions & 1 rubygems