Permalink
Browse files

Log instrumentation name for exists? queries

  • Loading branch information...
1 parent 6b3342d commit 618300f05a71bf728d9495c8f8226a8724c5a023 Jon Guymon committed Jun 22, 2011
@@ -193,8 +193,8 @@ def exists?(id = nil)
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
@@ -63,6 +63,14 @@ def test_basic_query_logging
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

0 comments on commit 618300f

Please sign in to comment.