Skip to content

Commit a8d6f26

Browse files
author
Anna
committed
moved
1 parent 9d249aa commit a8d6f26

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require 'active_record/test_case.rb'
2+
3+
# TODO: I'm struggling to figure out how to unsubscribe from only one 'sql.active_record'
4+
# This is a temporary hack until we can just get the sqlserver_ignored regex in rails
5+
ActiveSupport::Notifications.notifier.listeners_for('sql.active_record').each do |listener|
6+
if listener.inspect =~ /ActiveRecord::SQLCounter/
7+
ActiveSupport::Notifications.unsubscribe(listener)
8+
end
9+
end
10+
11+
module ActiveRecord
12+
class SQLCounter
13+
sqlserver_ignored = [%r|SELECT SCOPE_IDENTITY|, %r{INFORMATION_SCHEMA\.(TABLES|VIEWS|COLUMNS)},%r|SELECT @@version|, %r|SELECT @@TRANCOUNT|, %r{(BEGIN|COMMIT|ROLLBACK|SAVE) TRANSACTION}]
14+
ignored_sql.concat sqlserver_ignored
15+
end
16+
ActiveSupport::Notifications.subscribe('sql.active_record', SQLCounter.new)
17+
end

0 commit comments

Comments
 (0)