Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #371 #451

Closed

Conversation

baroquebobcat
Copy link
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.

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.
@josevalim
Copy link
Contributor

@tenderlove and @jonleighton ❤️

@jonleighton
Copy link
Member

Merged, thanks!

@jonleighton jonleighton closed this May 8, 2011
matthewd added a commit that referenced this pull request Apr 24, 2018
Fix Build: Allow failures from rubinius
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants