bullet 8.0.2 → 8.0.3
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 +4 -0
- data/lib/bullet/active_record4.rb +1 -1
- data/lib/bullet/active_record41.rb +1 -1
- data/lib/bullet/active_record42.rb +1 -1
- data/lib/bullet/active_record5.rb +1 -1
- data/lib/bullet/active_record52.rb +1 -1
- data/lib/bullet/active_record60.rb +1 -1
- data/lib/bullet/active_record61.rb +1 -1
- data/lib/bullet/active_record70.rb +1 -1
- data/lib/bullet/active_record71.rb +1 -1
- data/lib/bullet/active_record72.rb +1 -1
- data/lib/bullet/active_record80.rb +1 -1
- data/lib/bullet/detector/n_plus_one_query.rb +13 -3
- data/lib/bullet/registry/base.rb +5 -1
- data/lib/bullet/version.rb +1 -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: 0b32cc08a4de57560f18996d4ff4c96cb7a8cbc36cfb6dc285f612ac8ccd8f2e
|
4
|
+
data.tar.gz: 1d5b9e6f885039b6a3208d546b2ebad0a44e8063c4e1fffc7d74790ba79c1f71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb317b0bab9154eb40be0a315f1fe767ff8c227f631ee6b25e270c31422fb6aa7b4857ae7cb33b9155eb8a2300a1c52d6097fef899ad02b7cae42c8c7082e2a6
|
7
|
+
data.tar.gz: ba13a423de83f43a6a5a2d75a576e4612011c21cf835f2204cda2b02114680f03cf397b7d28f476eefd1c8e933da2a7e0ab9e860ee28f9e0dbbb1ecbf5abeef7
|
data/CHANGELOG.md
CHANGED
@@ -49,7 +49,7 @@ module Bullet
|
|
49
49
|
|
50
50
|
::ActiveRecord::Persistence.class_eval do
|
51
51
|
def _create_record_with_bullet(*args)
|
52
|
-
_create_record_without_bullet(*args).tap { Bullet::Detector::NPlusOneQuery.
|
52
|
+
_create_record_without_bullet(*args).tap { Bullet::Detector::NPlusOneQuery.update_inversed_object(self) }
|
53
53
|
end
|
54
54
|
alias_method_chain :_create_record, :bullet
|
55
55
|
end
|
@@ -52,7 +52,7 @@ module Bullet
|
|
52
52
|
|
53
53
|
::ActiveRecord::Persistence.class_eval do
|
54
54
|
def _create_record_with_bullet(*args)
|
55
|
-
_create_record_without_bullet(*args).tap { Bullet::Detector::NPlusOneQuery.
|
55
|
+
_create_record_without_bullet(*args).tap { Bullet::Detector::NPlusOneQuery.update_inversed_object(self) }
|
56
56
|
end
|
57
57
|
alias_method_chain :_create_record, :bullet
|
58
58
|
end
|
@@ -45,7 +45,7 @@ module Bullet
|
|
45
45
|
|
46
46
|
::ActiveRecord::Persistence.class_eval do
|
47
47
|
def _create_record_with_bullet(*args)
|
48
|
-
_create_record_without_bullet(*args).tap { Bullet::Detector::NPlusOneQuery.
|
48
|
+
_create_record_without_bullet(*args).tap { Bullet::Detector::NPlusOneQuery.update_inversed_object(self) }
|
49
49
|
end
|
50
50
|
alias_method_chain :_create_record, :bullet
|
51
51
|
end
|
@@ -67,13 +67,23 @@ module Bullet
|
|
67
67
|
def add_inversed_object(object, association)
|
68
68
|
return unless Bullet.start?
|
69
69
|
return unless Bullet.n_plus_one_query_enable?
|
70
|
-
return unless object.bullet_primary_key_value
|
71
70
|
|
71
|
+
object_key = object.bullet_primary_key_value ? object.bullet_key : object.object_id
|
72
72
|
Bullet.debug(
|
73
73
|
'Detector::NPlusOneQuery#add_inversed_object',
|
74
|
-
"object: #{
|
74
|
+
"object: #{object_key}, association: #{association}"
|
75
75
|
)
|
76
|
-
inversed_objects.add
|
76
|
+
inversed_objects.add object_key, association
|
77
|
+
end
|
78
|
+
|
79
|
+
def update_inversed_object(object)
|
80
|
+
if inversed_objects&.key?(object.object_id)
|
81
|
+
Bullet.debug(
|
82
|
+
'Detector::NPlusOneQuery#update_inversed_object',
|
83
|
+
"object from #{object.object_id} to #{object.bullet_key}"
|
84
|
+
)
|
85
|
+
inversed_objects.add(object.bullet_key, inversed_objects[object.object_id].to_a)
|
86
|
+
end
|
77
87
|
end
|
78
88
|
|
79
89
|
# decide whether the object.associations is unpreloaded or not.
|
data/lib/bullet/registry/base.rb
CHANGED
data/lib/bullet/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bullet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.0.
|
4
|
+
version: 8.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-04-
|
10
|
+
date: 2025-04-04 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: activesupport
|