Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Don't try to EXPLAIN select_db calls #10554

Merged
merged 1 commit into from

2 participants

@dasch

Backport of #10553.

@fxn

@fxn fxn merged commit 5cdd0bc into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 10, 2013
  1. @dasch
This page is out of date. Refresh to see the latest.
View
2  activerecord/lib/active_record/explain_subscriber.rb
@@ -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
View
5 activerecord/test/cases/explain_subscriber_test.rb
@@ -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
Something went wrong with that request. Please try again.