This project is archived and is in readonly mode.

#4123 ✓resolved
wtn

find_each ignores limit

Reported by wtn | March 7th, 2010 @ 10:45 AM | in 3.0.2

The following code iterates over the entire table, ignoring the limit scope:

klass.limit(3).find_each {|obj| puts obj.to_s}

In ActiveRecord 2.3, one could iterate over the first 3000 of 10000 records without loading all 3000 at once. In ActiveRecord 3.0, this is not possible.

find_each works with all other scope methods, so silently discarding limit scopes is inconsistent behavior. I suggest one of two options:

  1. find_each should ignore limits but issue a warning;
  2. find_each should behave as under ActiveRecord 2.3 and use the limit.

Comments and changes to this ticket

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>

People watching this ticket

Referenced by

Pages