Fix for #371 #451

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@baroquebobcat
Contributor

if a query contains a limit or an offset, ActiveRecord::FinderMethods#find_last had inconsistent behavior.

  • If the records were loaded, it returned the last record in the cached list.
  • If they were not, it reversed the order of the query and changed the limit to one.
  • If the earlier limit was less than the total matching the query in the db,
    it would return a different record than if the records had been cached.

This commit changes find_last so that it loads the records when getting the
last record on a query containing a limit or an offset, which makes the behavior consistent.

@baroquebobcat baroquebobcat Fix for #371
if a query contains a limit or an offset, ActiveRecord::FinderMethods#find_last had inconsistent behavior.

If the records were loaded, it returned the last record in the cached list.
If they were not, it reversed the order of the query and changed the limit to one.
If the earlier limit was less than the total matching the query in the db,
it would return a different record than if the records had been cached.

This commit changes find_last so that it loads the records when getting the
last record on a query containing a limit or an offset, which makes the behavior consistent.
95b2590
Member
Member

Merged, thanks!

@jonleighton jonleighton closed this May 8, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment