lib/dexter/query.rb in pgdexter-0.2.1 vs lib/dexter/query.rb in pgdexter-0.3.0

- old
+ new

@@ -1,8 +1,9 @@ module Dexter class Query attr_reader :statement, :fingerprint, :plans + attr_writer :tables attr_accessor :missing_tables, :new_cost, :total_time, :calls, :indexes, :suggest_index, :pass1_indexes, :pass2_indexes def initialize(statement, fingerprint = nil) @statement = statement unless fingerprint @@ -11,10 +12,18 @@ @fingerprint = fingerprint @plans = [] end def tables - @tables ||= parse ? parse.tables : [] + @tables ||= begin + parse ? parse.tables : [] + rescue => e + # possible pg_query bug + $stderr.puts "Error extracting tables. Please report to https://github.com/ankane/dexter/issues" + $stderr.puts "#{e.class.name}: #{e.message}" + $stderr.puts statement + [] + end end def tree parse.tree end