active_record-sql_analyzer 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7987c2a8d140ea3c6dc2b13effcad2f810562171
4
- data.tar.gz: b62f71e7563c8e92d11ee5baac0ad8722d669780
3
+ metadata.gz: cb06e648d1ffd4dea8993e522956e1f51e3a6c22
4
+ data.tar.gz: acfdcbbe3ee535851f8ae9ad7d7fbc93570733ce
5
5
  SHA512:
6
- metadata.gz: df3a2c7ea88fbc0b86cc9fdcc9fe94c52c9727ff436ade3f6f06869932f842c24101c33cbefe6bae77e381275572dcb6d4e724741c3bb18cd1ac5888d99da971
7
- data.tar.gz: 158608b3e248858f41a0084a6787432932e4860f41d48f876fd6cbbf58c9cad8a2eb7bbbb877eca8092fe50af1c7cc3d5aaf38518771111c6183de0b741b920b
6
+ metadata.gz: 5dc33540413a834ad211c77e473bf78de5dce8cb3fcf2221fe8c8d140249f2787d7bb6ed9961d106b5d123bb6bbb81eaec3cca02578ff29392ba80c67425c833
7
+ data.tar.gz: c15a89ef7b0e5ecd94d855dcde852554f34b2f08fea6fea924c9efc453c2c122ad6db32dce65f72f63a87e8e74603aaa860fb85d9bc7d3e33364aa51b3847807
@@ -44,18 +44,11 @@ module ActiveRecord
44
44
  QueryAnalyzerCall.new(call.sql.encode(Encoding::UTF_8, invalid: :replace, undef: :replace), call.caller)
45
45
  end
46
46
 
47
- matching_calls = reencoded_calls.select do |call|
48
- (call.sql =~ /^(UPDATE|INSERT|DELETE)/) || (call.sql =~ analyzer[:table_regex])
49
- end
50
-
51
- if matching_calls.any?
52
- # Add back in the begin and commit statements, using the correct call stack references
53
- if reencoded_calls.first.sql == 'BEGIN'
54
- matching_calls.unshift(reencoded_calls.first)
55
- end
47
+ has_matching_calls = reencoded_calls.any? { |call| call.sql =~ analyzer[:table_regex] }
56
48
 
57
- if ['COMMIT', 'ROLLBACK'].include? reencoded_calls.last.sql
58
- matching_calls << reencoded_calls.last
49
+ if has_matching_calls
50
+ matching_calls = reencoded_calls.select do |call|
51
+ (call.sql =~ /^(BEGIN|COMMIT|ROLLBACK|UPDATE|INSERT|DELETE)/) || (call.sql =~ analyzer[:table_regex])
59
52
  end
60
53
 
61
54
  SqlAnalyzer.background_processor <<
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module SqlAnalyzer
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.1'
4
4
  end
5
5
  end
@@ -241,6 +241,14 @@ RSpec.describe "End to End" do
241
241
  expect(log_def_hash.size).to eq(0)
242
242
  end
243
243
 
244
+ it "Does not log nonmatching-only insert transactions" do
245
+ transaction do
246
+ execute "INSERT INTO nonmatching_table (id) VALUES (1)"
247
+ end
248
+
249
+ expect(log_def_hash.size).to eq(0)
250
+ end
251
+
244
252
  context "Selectively sampling" do
245
253
  before do
246
254
  ActiveRecord::SqlAnalyzer.configure do |c|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record-sql_analyzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zachary Anker
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-08-16 00:00:00.000000000 Z
12
+ date: 2016-08-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord