aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJon Guymon <jguymon@igicom.com>2011-06-22 13:41:34 -0700
committerJon Guymon <jguymon@igicom.com>2011-06-22 13:41:34 -0700
commit618300f05a71bf728d9495c8f8226a8724c5a023 (patch)
treec4df1c24813ef4a3e90c08720f8ac0a806fb1aaf /activerecord
parent6b3342d971d4e127dceb351ef983ca650167518e (diff)
downloadrails-618300f05a71bf728d9495c8f8226a8724c5a023.tar.gz
rails-618300f05a71bf728d9495c8f8226a8724c5a023.tar.bz2
rails-618300f05a71bf728d9495c8f8226a8724c5a023.zip
Log instrumentation name for exists? queries
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/relation/finder_methods.rb4
-rw-r--r--activerecord/test/cases/log_subscriber_test.rb8
2 files changed, 10 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index c6e8762b4a..89f75fe3b2 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -193,8 +193,8 @@ module ActiveRecord
else
relation = relation.where(table[primary_key].eq(id)) if id
end
-
- connection.select_value(relation.to_sql) ? true : false
+
+ connection.select_value(relation.to_sql, "#{name} Exists") ? true : false
end
protected
diff --git a/activerecord/test/cases/log_subscriber_test.rb b/activerecord/test/cases/log_subscriber_test.rb
index c6c6079490..9e8475465e 100644
--- a/activerecord/test/cases/log_subscriber_test.rb
+++ b/activerecord/test/cases/log_subscriber_test.rb
@@ -63,6 +63,14 @@ class LogSubscriberTest < ActiveRecord::TestCase
assert_match(/SELECT .*?FROM .?developers.?/i, @logger.logged(:debug).last)
end
+ def test_exists_query_logging
+ Developer.exists? 1
+ wait
+ assert_equal 1, @logger.logged(:debug).size
+ assert_match(/Developer Exists/, @logger.logged(:debug).last)
+ assert_match(/SELECT .*?FROM .?developers.?/i, @logger.logged(:debug).last)
+ end
+
def test_cached_queries
ActiveRecord::Base.cache do
Developer.all