diff options
author | Xavier Noria <fxn@hashref.com> | 2011-11-25 14:29:34 -0800 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2011-11-25 14:29:34 -0800 |
commit | 1be9830d4d99e2bf56f1cadf74b843f22d66da35 (patch) | |
tree | f4acc78649b273bc1bf97fe4bb70e3ca9167ffbf /activerecord/lib | |
parent | a5b362df567ed4a0167a83e9b8f00b9f614ac38b (diff) | |
download | rails-1be9830d4d99e2bf56f1cadf74b843f22d66da35.tar.gz rails-1be9830d4d99e2bf56f1cadf74b843f22d66da35.tar.bz2 rails-1be9830d4d99e2bf56f1cadf74b843f22d66da35.zip |
add the query to AR::Relation#explain output
Rationale: this is more readable if serveral queries
are involved in one call. Also, it will be possible
to let AR log EXPLAINs automatically in production
mode, where queries are not even around.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index f0891440a6..0c32ad5139 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- require 'active_support/core_ext/object/blank' require 'active_support/core_ext/module/delegation' @@ -155,8 +156,8 @@ module ActiveRecord end queries.map do |sql| - @klass.connection.explain(sql) - end.join + "EXPLAIN for: #{sql}\n#{@klass.connection.explain(sql)}" + end.join("\n") end def to_a |