charkost / prosopite

:mag: Rails N+1 queries auto-detection with zero false positives / false negatives
Apache License 2.0
1.54k stars 46 forks source link

False positives for associations involving the same table #28

Closed kiriakosv closed 3 years ago

kiriakosv commented 3 years ago

There is a case of false positive N+1 warnings for a model with two associations pointing to the same table e.g.:

class AccountTransfer
  belongs_to :source, class_name: 'Account'
  belongs_to :target, class_name: 'Account'
end

Even if we include both associations to a fetching query, we get a warning for N+1s. I suspect that it fails to recognise that the extra query is part of the preloading.

charkost commented 3 years ago

Fixed, thanks for reporting this @kiriakosv!