aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2012-06-01 02:21:21 -0700
committerXavier Noria <fxn@hashref.com>2012-06-01 02:21:21 -0700
commitec9636e9dae5b1c479c6d811303dcc9b1f0d0782 (patch)
tree83d83982a7e3b5e5872808c897a02e0aab260aaa
parent47896d22d31ef0639d3b33b323a1f900713e30da (diff)
parentc1ea574b276389e565c38ff0584962afaefdeb2d (diff)
downloadrails-ec9636e9dae5b1c479c6d811303dcc9b1f0d0782.tar.gz
rails-ec9636e9dae5b1c479c6d811303dcc9b1f0d0782.tar.bz2
rails-ec9636e9dae5b1c479c6d811303dcc9b1f0d0782.zip
Merge pull request #6584 from amatsuda/ar_explain_inspect_readability
improve readability of AR explain result
-rw-r--r--activerecord/lib/active_record/explain.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/explain.rb b/activerecord/lib/active_record/explain.rb
index 313fdb3487..832b34a37e 100644
--- a/activerecord/lib/active_record/explain.rb
+++ b/activerecord/lib/active_record/explain.rb
@@ -52,7 +52,7 @@ module ActiveRecord
# Makes the adapter execute EXPLAIN for the tuples of queries and bindings.
# Returns a formatted string ready to be logged.
def exec_explain(queries) # :nodoc:
- queries && queries.map do |sql, bind|
+ str = queries && queries.map do |sql, bind|
[].tap do |msg|
msg << "EXPLAIN for: #{sql}"
unless bind.empty?
@@ -62,6 +62,12 @@ module ActiveRecord
msg << connection.explain(sql, bind)
end.join("\n")
end.join("\n")
+
+ # overriding inspect to be more human readable
+ def str.inspect
+ self
+ end
+ str
end
# Silences automatic EXPLAIN logging for the duration of the block.