This project is archived and is in readonly mode.
find_in_batches updates (+2 bugs)
Reported by eric.tipton (at gmail) | March 16th, 2009 @ 09:50 PM | in 2.x
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.
Comments and changes to this ticket
-
Frederick Cheung May 10th, 2009 @ 04:03 PM
- 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
-
Matthew Beale June 5th, 2009 @ 07:50 PM
I've got the scope fix in:
https://rails.lighthouseapp.com/projects/8994/tickets/2227-batches-...
With tests and all.
Also peeps on the same/similar topic:
https://rails.lighthouseapp.com/projects/8994/tickets/2128-activere...
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>