Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ActiveRecord::find_in_batches should take option[:order]

#2135

Currently the find_in_batches method raises an error if the :order option is passed to it. I do not understand what the harm in using the order option. However, here is a patch for to remove the error raised.

Thanks.

Reported by blj · March 5th, 2009 @ 01:19 PM

State: wontfix
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. CancelProfileIsBroken
    CancelProfileIsBroken

    -1

    AR::find_in_batches requires the table to be sorted in PK order because of the way it does the find. We shouldn't drop the warning unless you have a reimplementation that makes it possible to find in batches of arbitrary order.

    March 5th, 2009 @ 01:38 PM

  2. Ryan Angilly
    Ryan Angilly

    -1

    If, for example, you order by 'Name', and then while batch processing you insert a new record with the name "Angilly", it is possible (probable actually) that your batch processing will miss records. ID's are not very likely to change, and the auto-incrementing means it's much more difficult to miss records. This is also the reason that it requires integer ID's (and not UUIDs).

    Cheers, Ryan

    March 5th, 2009 @ 01:40 PM

  3. blj
    blj

    Mike, Ryan,

    Thanks. I see the problem. I will -1 it myself now :)

    March 5th, 2009 @ 01:55 PM

  4. CancelProfileIsBroken
    CancelProfileIsBroken
    • State changed from new to wontfix

    March 5th, 2009 @ 02:36 PM