model_iterator icon indicating copy to clipboard operation
model_iterator copied to clipboard

Iteration is broken when the AR model specifies its own default order via `default_scope`

Open mislav opened this issue 10 years ago • 0 comments

Take this example default scope:

default_scope :order => "created_at DESC"

The SQL queries resulting from model iterator for the above model will end up having this clause:

ORDER BY created_at DESC, id asc

Because the order is messed up right now, @current_id won't be properly maintained and the iterator will go through many more iterations of overlapping sets of records than it's needed.

The solution would be to ensure that the default_scope order is never inherited.

/cc @ptoomey3

mislav avatar Feb 19 '15 03:02 mislav