This project is archived and is in readonly mode.

#4869 ✓resolved
oleg dashevskii

[PATCH] A bug in ActiveRecord::Associations#using_limitable_reflections

Reported by oleg dashevskii | June 16th, 2010 @ 05:40 AM | in 2.3.9

After 2.3.5 to 2.3.8 transition I found unexpected breakage in my code:

OrderItem.sum(:quantity, {
  :joins => [:menu_item, :order], 
  :group => 'menu_items.dish_id', 
  :order => 'sum_quantity DESC', :limit => 10, 
  :conditions => { 'orders.user_id' => user.id }}.merge(options))

It tried to issue second SELECT query and substitute some ids, which is quite a nonsense here.
I investigated the problem and finally found that the breakage has been introduced in c48a71c7. Enumerable#reject was refactored into Enumerable#select, but it should be #collect.

The patch fixes the problem. I used #none? which is neater.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages