flyerhzm / bullet

help to kill N+1 queries and unused eager loading
MIT License
7.09k stars 433 forks source link

Is there a bug with whitelisting polymorphic associations? #564

Open aximuseng opened 3 years ago

aximuseng commented 3 years ago

I am getting these:

USE eager loading detected
  ActivityTask => [:taskable]
  Add to your query: .includes([:taskable])

The association is polymorphic so I can't add an include so I added a whitelist:

Bullet.add_whitelist type: :unused_eager_loading, class_name: "ActivityTask", association: :taskable

The bullet warnings persist even after adding this.

drnic commented 1 year ago

Broadly, how do we get Bullet to ignore polymorphic associations? It complains that they aren't eagerly loaded, but later complains that they are polymorphic.

Update: I found Bullet.add_safelist to exclude each specific scenario