drnic/composite_primary_keys — pull request #150 by jordanbyron (2013-04-03 19:56:03+00:00)
Title: find_in_batches should use lexicographic order

Hi Folks!

The `find_in_batches` method is not working properly with multiple integer primary keys. This code uses the lexicographic order of the dataset to segment the batches properly.

The existing `find_in_batches` test does not properly check to see what happens after the first batch is yielded and there are more results in the database. I've added a new `find_each` test which forces the batch to run three times against a model with three primary keys (`RoomAssignment`). We could safely remove the `find_in_batches` test since it overlaps with the new `find_each` test, but that's up to you.

Also please note that I did not attempt to fix #148. The new logic was complicated enough were I thought it would be best to fix the simple case first, then take a swing at the more complicated example later.

Let me know if you have any questions / concerns. I tried to keep the code code as readable as possible but I am alway open to feedback.

Thanks for taking the time to maintain this project and a big thanks to @bradediger who helped me fix this problem :heart: Jordan