lib/pghero/methods/explain.rb in pghero-1.6.5 vs lib/pghero/methods/explain.rb in pghero-1.7.0
- old
+ new
@@ -2,17 +2,16 @@
module Methods
module Explain
def explain(sql)
sql = squish(sql)
explanation = nil
- explain_safe = explain_safe?
# use transaction for safety
connection_model.transaction do
# protect the DB with a 10 second timeout
# this could potentially increase the timeout, but 10 seconds should be okay
select_all("SET LOCAL statement_timeout = 10000")
- if (sql.sub(/;\z/, "").include?(";") || sql.upcase.include?("COMMIT")) && !explain_safe
+ if (sql.sub(/;\z/, "").include?(";") || sql.upcase.include?("COMMIT")) && !explain_safe?
raise ActiveRecord::StatementInvalid, "Unsafe statement"
end
explanation = select_all("EXPLAIN #{sql}").map { |v| v["QUERY PLAN"] }.join("\n")
raise ActiveRecord::Rollback
end