提交 ec9636e9 编写于 作者: X Xavier Noria

Merge pull request #6584 from amatsuda/ar_explain_inspect_readability

improve readability of AR explain result
......@@ -52,7 +52,7 @@ def collecting_queries_for_explain # :nodoc:
# 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 @@ def exec_explain(queries) # :nodoc:
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.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册