aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAkira Matsuda <ronnie@dio.jp>2012-05-31 16:58:17 +0900
committerAkira Matsuda <ronnie@dio.jp>2012-06-01 17:05:52 +0900
commitc1ea574b276389e565c38ff0584962afaefdeb2d (patch)
tree83d83982a7e3b5e5872808c897a02e0aab260aaa /activerecord
parent47896d22d31ef0639d3b33b323a1f900713e30da (diff)
downloadrails-c1ea574b276389e565c38ff0584962afaefdeb2d.tar.gz
rails-c1ea574b276389e565c38ff0584962afaefdeb2d.tar.bz2
rails-c1ea574b276389e565c38ff0584962afaefdeb2d.zip
improve readability of AR explain result
Diffstat (limited to 'activerecord')
-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.