Model.first and Model.last not passing a sql limit when a value is passed in #2783

joeytheman opened this Issue Sep 1, 2011 · 1 comment

3 participants


A SQL limit is not being passed when specifying a value for Model.first and Model.last.


pry(main)> User.first
  User Load (0.6ms)  SELECT `users`.* FROM `users` LIMIT 1

pry(main)> User.first(2)
  User Load (0.8ms)  SELECT `users`.* FROM `users` 


pry(main)> User.last
  User Load (0.5ms)  SELECT `users`.* FROM `users` ORDER BY `users`.`id` DESC LIMIT 1

pry(main)> User.last(2)
  User Load (0.9ms)  SELECT `users`.* FROM `users` 

Model.first(2) returns the first two records after retrieving all the records in memory.


I have fixed it. See #2789

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment