This project is archived and is in readonly mode.

#2135 ✓wontfix
blj

ActiveRecord::find_in_batches should take option[:order]

Reported by blj | March 5th, 2009 @ 01:19 PM | in 2.x

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.

Comments and changes to this ticket

  • CancelProfileIsBroken

    CancelProfileIsBroken March 5th, 2009 @ 01:38 PM

    -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.

  • Ryan Angilly

    Ryan Angilly March 5th, 2009 @ 01:40 PM

    -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

  • blj

    blj March 5th, 2009 @ 01:55 PM

    Mike, Ryan,

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

  • CancelProfileIsBroken

    CancelProfileIsBroken March 5th, 2009 @ 02:36 PM

    • State changed from “new” to “wontfix”

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>

Attachments

Referenced by

Pages