activerecord-hackery / squeel

Active Record, improved. Live again :)
http://erniemiller.org/2013/11/17/anyone-interested-in-activerecord-hackery/
MIT License
2.4k stars 213 forks source link

makes #reorder break #last #418

Open adrianomitre opened 8 years ago

adrianomitre commented 8 years ago

Steps to reproduce

$ rails new demo
$ cd demo
$ rails g model Person
$ rake db:migrate
$ rails c
> Person.reorder(:id).last
# SELECT  "people".* FROM "people"  ORDER BY "people"."id" DESC LIMIT 1
#=> nil

# add "gem 'squeel'" to Gemfile
$ bundle install
$ rails c
> Person.reorder(:id).last
# SELECT  "people".* FROM "people"  ORDER BY "people"."id" ASC LIMIT 1
#=> nil

Expected behavior

> Person.reorder(:id).last
# SELECT  "people".* FROM "people"  ORDER BY "people"."id" DESC LIMIT 1
#=> nil

Actual behavior

> Person.reorder(:id).last
# SELECT  "people".* FROM "people"  ORDER BY "people"."id" ASC LIMIT 1
#=> nil

System configuration

Rails version: 4.2.6 (as well as 4.2.5.2) Ruby version: ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]

PS: This issue supersedes https://github.com/rails/rails/issues/24442 and https://github.com/rails/rails/issues/24443