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.

find_in_batches updates (+2 bugs)

#2260

BUG 1: When given a :select that doesn't contain the primary key, this method will fail.

BUG 2: Method was calling instance.id in one spot (should be instance.send(primary_key))

requested updates -- I modified the method to: 1.) accept :limit and :offset 2.) accept :start_with_zero (defaults to true). If :start is NOT provided, this will cause method to look for primary_key >= 0 on first batch. If false, the method will do find(:first) to find the initial "start" value. If :start IS provided, this is not used at all. This allows non-integer primary keys to be used.

attached is my version of activerecord/lib/active_record/batches.rb containing the updates and bug fixes (the only method changed is find_in_batches)

I have not done extensive unit tests. Will post when I have done that.

Reported by eric.tipton (at gmail) · March 16th, 2009 @ 09:50 PM

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

Activity

  1. eric.tipton (at gmail)
    eric.tipton (at gmail)

    updated to account for bug 2128

    March 24th, 2009 @ 09:03 AM

  2. eric.tipton (at gmail)
  3. Frederick Cheung
    Frederick Cheung
    • State changed from new to incomplete

    Hi eric,

    thanks for the work you've done, however you should check out the contributor guide ( https://rails.lighthouseapp.com/... ). When you just submit an entire file like that it's harder to see the changes you've made (and potentially easy to squash other updates to batches.rb)

    I'd also really recommend you separate out your bug fixes from the non bug changes you've made

    May 10th, 2009 @ 04:03 PM

  4. Matthew Beale
  5. Ryan Bigg
    Ryan Bigg
    • State changed from incomplete to resolved

    Fixed in #2227

    April 15th, 2010 @ 01:43 AM