bullet
bullet copied to clipboard
has_many through with order clause not being picked up as n+1
I have reproduced the issue in the following test:
https://github.com/kbaum/bullet_test/blob/master/test/unit/user_space_test.rb
For some reason, when we have the order on the has_many users, the test has an n+1.
has_many :users, :through => :user_spaces,
:order=>'user_spaces.position, user_spaces.id'
The problem is that bullet does not catch this n+1 for some reason. I get the following output when i run the test:
http://vts-monosnap.s3.amazonaws.com/bullet_test__bash__36285_2014-07-24_17-11-26_2014-07-24_17-12-09.jpg
thx!
-karl
@kbaum didn't you think it's a rails bug? it already eager loads user_spaces and then load them one by one again.
I definitely agree that it's a rails bug but was thinking it would be helpful if bullet reported all n+1 occurrences regardless of whether it's a rails bug or not.
Thx!
— Sent from Mailbox
On Sat, Jul 26, 2014 at 12:58 AM, Richard Huang [email protected] wrote:
@kbaum didn't you think it's a rails bug? it already eager loads user_spaces and then load them one by one again.
Reply to this email directly or view it on GitHub: https://github.com/flyerhzm/bullet/issues/179#issuecomment-50223482
@kbaum in case bullet can detect such n+1 queries, how will you fix it?
If I explicitly include user_spaces, it fixes or if I taker the order clause away from the has many through and instead order from within memory.— Sent from Mailbox
On Sat, Jul 26, 2014 at 8:13 AM, Richard Huang [email protected] wrote:
@kbaum in case bullet can detect such n+1 queries, how will you fix it?
Reply to this email directly or view it on GitHub: https://github.com/flyerhzm/bullet/issues/179#issuecomment-50232475
@kbaum I'll try
Thx!— Sent from Mailbox
On Sun, Jul 27, 2014 at 11:56 PM, Richard Huang [email protected] wrote:
@kbaum I'll try
Reply to this email directly or view it on GitHub: https://github.com/flyerhzm/bullet/issues/179#issuecomment-50298221
+1