aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2011-07-10 18:02:31 -0700
committerSantiago Pastorino <santiago@wyeworks.com>2011-07-10 18:02:31 -0700
commitc3732bfed01de49947dd0aedd8cc976128b7f5db (patch)
tree435b177788278fa545bea71a781d7831fd3dda1d /activerecord
parent60076de1d416a68dc52804041f3c8586578acbd9 (diff)
parent618300f05a71bf728d9495c8f8226a8724c5a023 (diff)
downloadrails-c3732bfed01de49947dd0aedd8cc976128b7f5db.tar.gz
rails-c3732bfed01de49947dd0aedd8cc976128b7f5db.tar.bz2
rails-c3732bfed01de49947dd0aedd8cc976128b7f5db.zip
Merge pull request #1823 from gnarg/master
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 422d89060b..283115a448 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