bullet 7.1.0 → 7.1.2
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 +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/bullet/active_record4.rb +2 -2
- data/lib/bullet/active_record41.rb +2 -2
- data/lib/bullet/active_record42.rb +2 -2
- data/lib/bullet/active_record5.rb +4 -1
- data/lib/bullet/active_record52.rb +6 -3
- data/lib/bullet/active_record60.rb +4 -1
- data/lib/bullet/active_record61.rb +6 -3
- data/lib/bullet/active_record70.rb +12 -5
- data/lib/bullet/active_record71.rb +12 -5
- data/lib/bullet/detector/n_plus_one_query.rb +2 -5
- data/lib/bullet/detector/unused_eager_loading.rb +4 -1
- data/lib/bullet/ext/object.rb +13 -3
- data/lib/bullet/mongoid8x.rb +1 -1
- data/lib/bullet/notification/base.rb +9 -8
- data/lib/bullet/rack.rb +3 -1
- data/lib/bullet/registry/association.rb +2 -1
- data/lib/bullet/stack_trace_filter.rb +3 -2
- data/lib/bullet/version.rb +1 -1
- data/lib/bullet.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c62bb5eb8bdfdb62ce49a79609ce7665d6af8be0f7dede7361379597415dcd4
|
4
|
+
data.tar.gz: 8da00673c07b79eb6dbf7b061aaf6dd0208fd0be841a96c3169ba919259fcf82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f33ad269a72ba293680c65ed460ef4e598446eebf62c82d79879de03b3cb52098f27499cab681facec3fdc3a3d6f937d064c21621aefcc69edcf499a52680838
|
7
|
+
data.tar.gz: 4a386c2bda2cdea90926ce9ff8bca0932954507ac4fa1e5986a356d869c3fb410b48708a5de843fb0e1f822f744ef1cf26dcecc9036ad3036f774ffad1c6e84e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
## Next Release
|
2
2
|
|
3
|
+
## 7.1.2 (10/13/2023)
|
4
|
+
|
5
|
+
* Handle Rails 7.1 composite primary keys
|
6
|
+
|
7
|
+
## 7.1.1 (10/07/2023)
|
8
|
+
|
9
|
+
* Add support for `Content-Security-Policy-Report-Only` nonces
|
10
|
+
* Fix count method signature
|
11
|
+
|
3
12
|
## 7.1.0 (10/06/2023)
|
4
13
|
|
5
14
|
* Support rails 7.1
|
@@ -178,11 +178,11 @@ module Bullet
|
|
178
178
|
end
|
179
179
|
|
180
180
|
::ActiveRecord::Associations::CollectionProxy.class_eval do
|
181
|
-
def count
|
181
|
+
def count(column_name = nil, options = {})
|
182
182
|
if Bullet.start?
|
183
183
|
Bullet::Detector::CounterCache.add_counter_cache(proxy_association.owner, proxy_association.reflection.name)
|
184
184
|
end
|
185
|
-
super
|
185
|
+
super(column_name, options)
|
186
186
|
end
|
187
187
|
end
|
188
188
|
end
|
@@ -170,11 +170,11 @@ module Bullet
|
|
170
170
|
end
|
171
171
|
|
172
172
|
::ActiveRecord::Associations::CollectionProxy.class_eval do
|
173
|
-
def count
|
173
|
+
def count(column_name = nil, options = {})
|
174
174
|
if Bullet.start?
|
175
175
|
Bullet::Detector::CounterCache.add_counter_cache(proxy_association.owner, proxy_association.reflection.name)
|
176
176
|
end
|
177
|
-
super
|
177
|
+
super(column_name, options)
|
178
178
|
end
|
179
179
|
end
|
180
180
|
end
|
@@ -235,11 +235,11 @@ module Bullet
|
|
235
235
|
end
|
236
236
|
|
237
237
|
::ActiveRecord::Associations::CollectionProxy.class_eval do
|
238
|
-
def count
|
238
|
+
def count(column_name = nil, options = {})
|
239
239
|
if Bullet.start?
|
240
240
|
Bullet::Detector::CounterCache.add_counter_cache(proxy_association.owner, proxy_association.reflection.name)
|
241
241
|
end
|
242
|
-
super
|
242
|
+
super(column_name, options)
|
243
243
|
end
|
244
244
|
end
|
245
245
|
end
|
@@ -265,7 +265,10 @@ module Bullet
|
|
265
265
|
Module.new do
|
266
266
|
def count
|
267
267
|
if Bullet.start? && !proxy_association.is_a?(::ActiveRecord::Associations::ThroughAssociation)
|
268
|
-
Bullet::Detector::CounterCache.add_counter_cache(
|
268
|
+
Bullet::Detector::CounterCache.add_counter_cache(
|
269
|
+
proxy_association.owner,
|
270
|
+
proxy_association.reflection.name
|
271
|
+
)
|
269
272
|
end
|
270
273
|
super
|
271
274
|
end
|
@@ -245,11 +245,14 @@ module Bullet
|
|
245
245
|
|
246
246
|
::ActiveRecord::Associations::CollectionProxy.prepend(
|
247
247
|
Module.new do
|
248
|
-
def count
|
248
|
+
def count(column_name = nil)
|
249
249
|
if Bullet.start? && !proxy_association.is_a?(::ActiveRecord::Associations::ThroughAssociation)
|
250
|
-
Bullet::Detector::CounterCache.add_counter_cache(
|
250
|
+
Bullet::Detector::CounterCache.add_counter_cache(
|
251
|
+
proxy_association.owner,
|
252
|
+
proxy_association.reflection.name
|
253
|
+
)
|
251
254
|
end
|
252
|
-
super
|
255
|
+
super(column_name)
|
253
256
|
end
|
254
257
|
end
|
255
258
|
)
|
@@ -274,7 +274,10 @@ module Bullet
|
|
274
274
|
Module.new do
|
275
275
|
def count
|
276
276
|
if Bullet.start? && !proxy_association.is_a?(::ActiveRecord::Associations::ThroughAssociation)
|
277
|
-
Bullet::Detector::CounterCache.add_counter_cache(
|
277
|
+
Bullet::Detector::CounterCache.add_counter_cache(
|
278
|
+
proxy_association.owner,
|
279
|
+
proxy_association.reflection.name
|
280
|
+
)
|
278
281
|
end
|
279
282
|
super
|
280
283
|
end
|
@@ -272,11 +272,14 @@ module Bullet
|
|
272
272
|
|
273
273
|
::ActiveRecord::Associations::CollectionProxy.prepend(
|
274
274
|
Module.new do
|
275
|
-
def count
|
275
|
+
def count(column_name = nil)
|
276
276
|
if Bullet.start? && !proxy_association.is_a?(::ActiveRecord::Associations::ThroughAssociation)
|
277
|
-
Bullet::Detector::CounterCache.add_counter_cache(
|
277
|
+
Bullet::Detector::CounterCache.add_counter_cache(
|
278
|
+
proxy_association.owner,
|
279
|
+
proxy_association.reflection.name
|
280
|
+
)
|
278
281
|
end
|
279
|
-
super
|
282
|
+
super(column_name)
|
280
283
|
end
|
281
284
|
end
|
282
285
|
)
|
@@ -65,7 +65,9 @@ module Bullet
|
|
65
65
|
def call
|
66
66
|
if Bullet.start?
|
67
67
|
@preloaders.each do |preloader|
|
68
|
-
preloader.records.each { |record|
|
68
|
+
preloader.records.each { |record|
|
69
|
+
Bullet::Detector::Association.add_object_associations(record, preloader.associations)
|
70
|
+
}
|
69
71
|
Bullet::Detector::UnusedEagerLoading.add_eager_loadings(preloader.records, preloader.associations)
|
70
72
|
end
|
71
73
|
end
|
@@ -80,7 +82,9 @@ module Bullet
|
|
80
82
|
if Bullet.start?
|
81
83
|
reflection_records.compact!
|
82
84
|
if reflection_records.first.class.name !~ /^HABTM_/
|
83
|
-
reflection_records.each { |record|
|
85
|
+
reflection_records.each { |record|
|
86
|
+
Bullet::Detector::Association.add_object_associations(record, reflection.name)
|
87
|
+
}
|
84
88
|
Bullet::Detector::UnusedEagerLoading.add_eager_loadings(reflection_records, reflection.name)
|
85
89
|
end
|
86
90
|
end
|
@@ -284,11 +288,14 @@ module Bullet
|
|
284
288
|
|
285
289
|
::ActiveRecord::Associations::CollectionProxy.prepend(
|
286
290
|
Module.new do
|
287
|
-
def count
|
291
|
+
def count(column_name = nil)
|
288
292
|
if Bullet.start? && !proxy_association.is_a?(::ActiveRecord::Associations::ThroughAssociation)
|
289
|
-
Bullet::Detector::CounterCache.add_counter_cache(
|
293
|
+
Bullet::Detector::CounterCache.add_counter_cache(
|
294
|
+
proxy_association.owner,
|
295
|
+
proxy_association.reflection.name
|
296
|
+
)
|
290
297
|
end
|
291
|
-
super
|
298
|
+
super(column_name)
|
292
299
|
end
|
293
300
|
end
|
294
301
|
)
|
@@ -65,7 +65,9 @@ module Bullet
|
|
65
65
|
def call
|
66
66
|
if Bullet.start?
|
67
67
|
@preloaders.each do |preloader|
|
68
|
-
preloader.records.each { |record|
|
68
|
+
preloader.records.each { |record|
|
69
|
+
Bullet::Detector::Association.add_object_associations(record, preloader.associations)
|
70
|
+
}
|
69
71
|
Bullet::Detector::UnusedEagerLoading.add_eager_loadings(preloader.records, preloader.associations)
|
70
72
|
end
|
71
73
|
end
|
@@ -80,7 +82,9 @@ module Bullet
|
|
80
82
|
if Bullet.start?
|
81
83
|
reflection_records.compact!
|
82
84
|
if reflection_records.first.class.name !~ /^HABTM_/
|
83
|
-
reflection_records.each { |record|
|
85
|
+
reflection_records.each { |record|
|
86
|
+
Bullet::Detector::Association.add_object_associations(record, reflection.name)
|
87
|
+
}
|
84
88
|
Bullet::Detector::UnusedEagerLoading.add_eager_loadings(reflection_records, reflection.name)
|
85
89
|
end
|
86
90
|
end
|
@@ -284,11 +288,14 @@ module Bullet
|
|
284
288
|
|
285
289
|
::ActiveRecord::Associations::CollectionProxy.prepend(
|
286
290
|
Module.new do
|
287
|
-
def count
|
291
|
+
def count(column_name = nil)
|
288
292
|
if Bullet.start? && !proxy_association.is_a?(::ActiveRecord::Associations::ThroughAssociation)
|
289
|
-
Bullet::Detector::CounterCache.add_counter_cache(
|
293
|
+
Bullet::Detector::CounterCache.add_counter_cache(
|
294
|
+
proxy_association.owner,
|
295
|
+
proxy_association.reflection.name
|
296
|
+
)
|
290
297
|
end
|
291
|
-
super
|
298
|
+
super(column_name)
|
292
299
|
end
|
293
300
|
end
|
294
301
|
)
|
@@ -44,13 +44,10 @@ module Bullet
|
|
44
44
|
unless obj.bullet_primary_key_value.nil?
|
45
45
|
primary_key_values_are_empty = false
|
46
46
|
end
|
47
|
-
keys_joined += "#{(keys_joined.empty
|
47
|
+
keys_joined += "#{(keys_joined.empty? ? '' : ', ')}#{obj.bullet_key}"
|
48
48
|
end
|
49
49
|
unless class_names_match_regex || primary_key_values_are_empty
|
50
|
-
Bullet.debug(
|
51
|
-
'Detector::NPlusOneQuery#add_possible_objects',
|
52
|
-
"objects: #{keys_joined}"
|
53
|
-
)
|
50
|
+
Bullet.debug('Detector::NPlusOneQuery#add_possible_objects', "objects: #{keys_joined}")
|
54
51
|
objects.each { |object| possible_objects.add object.bullet_key }
|
55
52
|
end
|
56
53
|
end
|
@@ -65,7 +65,10 @@ module Bullet
|
|
65
65
|
private
|
66
66
|
|
67
67
|
def create_notification(callers, klazz, associations)
|
68
|
-
notify_associations = Array.wrap(associations) - Bullet.get_safelist_associations(
|
68
|
+
notify_associations = Array.wrap(associations) - Bullet.get_safelist_associations(
|
69
|
+
:unused_eager_loading,
|
70
|
+
klazz
|
71
|
+
)
|
69
72
|
|
70
73
|
if notify_associations.present?
|
71
74
|
notice = Bullet::Notification::UnusedEagerLoading.new(callers, klazz, notify_associations)
|
data/lib/bullet/ext/object.rb
CHANGED
@@ -9,11 +9,21 @@ class Object
|
|
9
9
|
return if respond_to?(:persisted?) && !persisted?
|
10
10
|
|
11
11
|
if self.class.respond_to?(:primary_keys) && self.class.primary_keys
|
12
|
-
self.class.primary_keys
|
12
|
+
primary_key = self.class.primary_keys
|
13
13
|
elsif self.class.respond_to?(:primary_key) && self.class.primary_key
|
14
|
-
|
14
|
+
primary_key = self.class.primary_key
|
15
15
|
else
|
16
|
-
id
|
16
|
+
primary_key = :id
|
17
17
|
end
|
18
|
+
|
19
|
+
bullet_join_potential_composite_primary_key(primary_key)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def bullet_join_potential_composite_primary_key(primary_keys)
|
25
|
+
return send(primary_keys) unless primary_keys.is_a?(Enumerable)
|
26
|
+
|
27
|
+
primary_keys.map { |primary_key| send primary_key }.join(',')
|
18
28
|
end
|
19
29
|
end
|
data/lib/bullet/mongoid8x.rb
CHANGED
@@ -28,13 +28,13 @@ module Bullet
|
|
28
28
|
def whoami
|
29
29
|
@user ||=
|
30
30
|
ENV['USER'].presence ||
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
31
|
+
(
|
32
|
+
begin
|
33
|
+
`whoami`.chomp
|
34
|
+
rescue StandardError
|
35
|
+
''
|
36
|
+
end
|
37
|
+
)
|
38
38
|
@user.present? ? "user: #{@user}" : ''
|
39
39
|
end
|
40
40
|
|
@@ -73,7 +73,8 @@ module Bullet
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def associations_str
|
76
|
-
".includes(#{@associations.map { |a| a.to_s.to_sym }
|
76
|
+
".includes(#{@associations.map { |a| a.to_s.to_sym }
|
77
|
+
.inspect})"
|
77
78
|
end
|
78
79
|
end
|
79
80
|
end
|
data/lib/bullet/rack.rb
CHANGED
@@ -49,6 +49,7 @@ module Bullet
|
|
49
49
|
# response may be ["Not Found"], ["Move Permanently"], etc, but
|
50
50
|
# those should not happen if the status is 200
|
51
51
|
return true if !response.respond_to?(:body) && !response.respond_to?(:first)
|
52
|
+
|
52
53
|
body = response_body(response)
|
53
54
|
body.nil? || body.empty?
|
54
55
|
end
|
@@ -135,7 +136,8 @@ module Bullet
|
|
135
136
|
end
|
136
137
|
|
137
138
|
def with_security_policy_nonce(headers)
|
138
|
-
|
139
|
+
csp = headers['Content-Security-Policy'] || headers['Content-Security-Policy-Report-Only'] || ''
|
140
|
+
matched = csp.match(NONCE_MATCHER)
|
139
141
|
nonce = matched[:nonce] if matched
|
140
142
|
|
141
143
|
if nonce
|
@@ -8,7 +8,8 @@ module Bullet
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def similarly_associated(base, associations)
|
11
|
-
@registry.select { |key, value| key.include?(base) && value == associations }
|
11
|
+
@registry.select { |key, value| key.include?(base) && value == associations }
|
12
|
+
.collect(&:first).flatten
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "bundler"
|
3
4
|
|
4
5
|
module Bullet
|
@@ -14,8 +15,8 @@ module Bullet
|
|
14
15
|
caller_path = location_as_path(location)
|
15
16
|
caller_path.include?(Bullet.app_root) && !caller_path.include?(vendor_root) &&
|
16
17
|
!caller_path.include?(bundler_path) || Bullet.stacktrace_includes.any? { |include_pattern|
|
17
|
-
|
18
|
-
|
18
|
+
pattern_matches?(location, include_pattern)
|
19
|
+
}
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
data/lib/bullet/version.rb
CHANGED
data/lib/bullet.rb
CHANGED
@@ -43,7 +43,8 @@ module Bullet
|
|
43
43
|
attr_accessor :add_footer, :orm_patches_applied, :skip_http_headers, :always_append_html_body
|
44
44
|
|
45
45
|
available_notifiers =
|
46
|
-
UniformNotifier::AVAILABLE_NOTIFIERS.select { |notifier| notifier != :raise }
|
46
|
+
UniformNotifier::AVAILABLE_NOTIFIERS.select { |notifier| notifier != :raise }
|
47
|
+
.map { |notifier| "#{notifier}=" }
|
47
48
|
available_notifiers_options = { to: UniformNotifier }
|
48
49
|
delegate(*available_notifiers, **available_notifiers_options)
|
49
50
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bullet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.1.
|
4
|
+
version: 7.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|