Skip to content

Commit

Permalink
Fix eager_load nested has_many :through false positives
Browse files Browse the repository at this point in the history
  • Loading branch information
adamzapasnik committed Dec 8, 2022
1 parent 47de85c commit 0bb4182
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions lib/bullet/active_record5.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,12 @@ def load_target
Array.wrap(association.target).each do |through_record|
Bullet::Detector::NPlusOneQuery.call_association(through_record, source_reflection.name)
end
end

if refl.through_reflection?
refl = refl.through_reflection while refl.through_reflection?
if refl.through_reflection?
refl = refl.through_reflection while refl.through_reflection?

Bullet::Detector::NPlusOneQuery.call_association(owner, refl.name)
Bullet::Detector::NPlusOneQuery.call_association(owner, refl.name)
end
end
end
Bullet::Detector::NPlusOneQuery.call_association(owner, reflection.name) unless @inversed
Expand Down
6 changes: 3 additions & 3 deletions lib/bullet/active_record52.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ def load_target
Array.wrap(association.target).each do |through_record|
Bullet::Detector::NPlusOneQuery.call_association(through_record, source_reflection.name)
end
end

if reflection.through_reflection != through_reflection
Bullet::Detector::NPlusOneQuery.call_association(owner, through_reflection.name)
if reflection.through_reflection != through_reflection
Bullet::Detector::NPlusOneQuery.call_association(owner, through_reflection.name)
end
end
end
Bullet::Detector::NPlusOneQuery.call_association(owner, reflection.name) unless @inversed
Expand Down
6 changes: 3 additions & 3 deletions lib/bullet/active_record60.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ def load_target
Array.wrap(association.target).each do |through_record|
Bullet::Detector::NPlusOneQuery.call_association(through_record, source_reflection.name)
end
end

if reflection.through_reflection != through_reflection
Bullet::Detector::NPlusOneQuery.call_association(owner, through_reflection.name)
if reflection.through_reflection != through_reflection
Bullet::Detector::NPlusOneQuery.call_association(owner, through_reflection.name)
end
end
end
Bullet::Detector::NPlusOneQuery.call_association(owner, reflection.name) unless @inversed
Expand Down
6 changes: 3 additions & 3 deletions lib/bullet/active_record61.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ def load_target
Array.wrap(association.target).each do |through_record|
Bullet::Detector::NPlusOneQuery.call_association(through_record, source_reflection.name)
end
end

if reflection.through_reflection != through_reflection
Bullet::Detector::NPlusOneQuery.call_association(owner, through_reflection.name)
if reflection.through_reflection != through_reflection
Bullet::Detector::NPlusOneQuery.call_association(owner, through_reflection.name)
end
end
end
Bullet::Detector::NPlusOneQuery.call_association(owner, reflection.name) unless @inversed
Expand Down
6 changes: 3 additions & 3 deletions lib/bullet/active_record70.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ def load_target
Array.wrap(association.target).each do |through_record|
Bullet::Detector::NPlusOneQuery.call_association(through_record, source_reflection.name)
end
end

if reflection.through_reflection != through_reflection
Bullet::Detector::NPlusOneQuery.call_association(owner, through_reflection.name)
if reflection.through_reflection != through_reflection
Bullet::Detector::NPlusOneQuery.call_association(owner, through_reflection.name)
end
end
end
Bullet::Detector::NPlusOneQuery.call_association(owner, reflection.name)
Expand Down

0 comments on commit 0bb4182

Please sign in to comment.