Permalink
Browse files

Don't try to EXPLAIN select_db calls

  • Loading branch information...
1 parent 1296adb commit 868455672a16e268ce287e0de4ddc7451460df6d @dasch dasch committed May 10, 2013
@@ -19,7 +19,7 @@ def finish(name, id, payload)
# On the other hand, we want to monitor the performance of our real database
# queries, not the performance of the access to the query cache.
IGNORED_PAYLOADS = %w(SCHEMA EXPLAIN CACHE)
- EXPLAINED_SQLS = /\A\s*(select|update|delete|insert)/i
+ EXPLAINED_SQLS = /\A\s*(select|update|delete|insert)\b/i
def ignore_payload?(payload)
payload[:exception] || IGNORED_PAYLOADS.include?(payload[:name]) || payload[:sql] !~ EXPLAINED_SQLS
end
@@ -43,6 +43,11 @@ def test_collects_nothing_if_the_statement_is_not_whitelisted
assert queries.empty?
end
+ def test_collects_nothing_if_the_statement_is_only_partially_matched
+ SUBSCRIBER.finish(nil, nil, name: 'SQL', sql: 'select_db yo_mama')
+ assert queries.empty?
+ end
+
def teardown
ActiveRecord::ExplainRegistry.reset
end

0 comments on commit 8684556

Please sign in to comment.