bullet
bullet copied to clipboard
Factory bot created resources - AVOID eager loading detected
This started happening after upgrade to 5.8.1 from 5.7.5 We use Factory bot to create resources for testing and when creating a record with association Bullet complains about unnecessary eager loading. Here's an example:
@grade = create :grade, grade_descriptor: @grade_descriptor1 # factory bot create
@grade.update_grade_descriptor @grade_descriptor2
expect(@grade.grade_descriptor).to eq @grade_descriptor2
AVOID eager loading detected
Grade => [:grade_descriptor]
Remove from your finder: :includes => [:grade_descriptor]
I guess that it doesn't like the fact that the first grade_descriptor was loaded and didn't even get used, which makes sense; however, it would be great if it could somehow ignore resources created via factories.
We are having the same issue.
Same here. No solution in sight yet?
same here
I encounter the same problem. Any hints highly appreciated.
My observation is that it works in the combination of bullet (5.7.5)
and factory_bot (4.11.1)
, but neither with bullet (5.9.0)
nor bullet (5.7.6)
.
I am still having problems with 5.7.5
.
I have a factory like this
FactoryBot.define do
factory :ticket do
...
trip_segment do
trip = create(:trip)
trip.trip_segments.first
end
...
end
end
And I get this
USE eager loading detected
Ticket => [:trip]
Add to your finder: :includes => [:trip]
What is wrong?
I checked if it works with bullet (5.9.0)
, and it does. The spec using that factory passes, but having the same AVOID eager loading
problem with others.
It looks like for my problem the PR that introduced it was https://github.com/flyerhzm/bullet/pull/418
can replicate it using
class Foo < ActiveRecord::Base
belongs_to :bar
end
class Bar < ActiveRecord::Base
end
Foo.create; Bar.create
Bullet.profile do
foo = Foo.first
foo.bar = Bar.first
end
AVOID eager loading detected
Foo => [:bar]
Remove from your finder: :includes => [:bar]
I have quite a limited understanding of how bullet works but Is this the intended behaviour @ccutrer ?
@flyerhzm Any update on this issue?
Anything new we can do on this?
Anything new we can do on this?
Can we use the safelist for factories?