Skip to content

Commit c1ea574

Browse files
committed
improve readability of AR explain result
1 parent 47896d2 commit c1ea574

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

activerecord/lib/active_record/explain.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def collecting_queries_for_explain # :nodoc:
5252
# Makes the adapter execute EXPLAIN for the tuples of queries and bindings.
5353
# Returns a formatted string ready to be logged.
5454
def exec_explain(queries) # :nodoc:
55-
queries && queries.map do |sql, bind|
55+
str = queries && queries.map do |sql, bind|
5656
[].tap do |msg|
5757
msg << "EXPLAIN for: #{sql}"
5858
unless bind.empty?
@@ -62,6 +62,12 @@ def exec_explain(queries) # :nodoc:
6262
msg << connection.explain(sql, bind)
6363
end.join("\n")
6464
end.join("\n")
65+
66+
# overriding inspect to be more human readable
67+
def str.inspect
68+
self
69+
end
70+
str
6571
end
6672

6773
# Silences automatic EXPLAIN logging for the duration of the block.

0 commit comments

Comments
 (0)