Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

makes #reorder break #last #418

Open
adrianomitre opened this issue Apr 6, 2016 · 0 comments
Open

makes #reorder break #last #418

adrianomitre opened this issue Apr 6, 2016 · 0 comments

Comments

@adrianomitre
Copy link

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 rails/rails#24442 and rails/rails#24443

yez pushed a commit to yez/squeel that referenced this issue Apr 15, 2016
This should Resolve activerecord-hackery#418

Since the 4.1 version of `reverse_order!` is used, an additional check has been
 added to actually reorder the `ORDER BY` clause if there are non-nil elements
 of it.

A spec has been written to support this change.
yez pushed a commit to yez/squeel that referenced this issue Apr 15, 2016
This should Resolve activerecord-hackery#418

Since the 4.1 version of `reverse_order!` is used, an additional check has been
 added to actually reorder the `ORDER BY` clause if there are non-nil elements
 of it.

Additionally, a spec has been added to ensure proper ordering takes place.
yez pushed a commit to yez/squeel that referenced this issue Apr 15, 2016
This should Resolve activerecord-hackery#418

Since the 4.1 version of `reverse_order!` is used, an additional check has been
 added to actually reorder the `ORDER BY` clause if there are non-nil elements
 of it.

Additionally, a spec has been added to ensure proper ordering takes place.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant