aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2011-11-25 14:29:34 -0800
committerXavier Noria <fxn@hashref.com>2011-11-25 14:29:34 -0800
commit1be9830d4d99e2bf56f1cadf74b843f22d66da35 (patch)
treef4acc78649b273bc1bf97fe4bb70e3ca9167ffbf /activerecord/lib/active_record/relation.rb
parenta5b362df567ed4a0167a83e9b8f00b9f614ac38b (diff)
downloadrails-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/active_record/relation.rb')
-rw-r--r--activerecord/lib/active_record/relation.rb5
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