From 052fb973962243bed41cb1a448084475183b0c45 Mon Sep 17 00:00:00 2001 From: Kane York Date: Thu, 2 Jul 2015 08:50:11 -0700 Subject: [PATCH] Prevent AR from using percent parameters --- plugin.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugin.rb b/plugin.rb index 6a2d610..d6d1d22 100644 --- a/plugin.rb +++ b/plugin.rb @@ -85,6 +85,9 @@ after_initialize do query_args[k] = arg.to_i end end + # If we don't include this, then queries with a % sign in them fail + # because AR thinks we want percent-based parametes + query_args[:xxdummy] = 1 time_start, time_end, explain, err, result = nil begin @@ -98,6 +101,7 @@ after_initialize do * DataExplorer Query * Query: /admin/plugins/explorer?id=#{query.id} * Started by: #{opts[:current_user]} + * :xxdummy */ WITH query AS ( #{query.sql} @@ -110,7 +114,7 @@ SQL time_end = Time.now if opts[:explain] - explain = ActiveRecord::Base.exec_sql("EXPLAIN #{query.sql}", query_args) + explain = ActiveRecord::Base.exec_sql("-- :xxdummy \nEXPLAIN #{query.sql}", query_args) .map { |row| row["QUERY PLAN"] }.join "\n" end