active_record-sql_analyzer 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb06e648d1ffd4dea8993e522956e1f51e3a6c22
|
4
|
+
data.tar.gz: acfdcbbe3ee535851f8ae9ad7d7fbc93570733ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
58
|
-
|
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 <<
|
@@ -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.
|
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-
|
12
|
+
date: 2016-08-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|