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

QueryMethods#in_order_of drop records not listed #44097

Merged
merged 1 commit into from Jan 6, 2022

Conversation

kddnewton
Copy link
Contributor

in_order_of now filters down to the values provided, to match the behavior of the Enumerable version.

This is in response to #43916 (comment). It's working to match the Enumerable version, but since it was released I'm not sure of the migration path. Maybe it could be considered a bug and be a part of a patch release? Not sure.

`in_order_of` now filters down to the values provided, to match the behavior of the `Enumerable` version.

*Kevin Newton*
@rafaelfranca
Copy link
Member

Maybe it could be considered a bug and be a part of a patch release?

That was my plan, specially that it is only release for 3 weeks.

@AlexKovynev
Copy link

sorry for interfering, if you plan backport this to 7.0 maybe will be good to not forget backport original PR #43916

@rafaelfranca
Copy link
Member

@AlexKovynev not sure if I'm missing something, but I believe that PR is already there.

@rafaelfranca rafaelfranca merged commit ea7e58c into rails:main Jan 6, 2022
rafaelfranca added a commit that referenced this pull request Jan 6, 2022
`QueryMethods#in_order_of` drop records not listed
@chaadow
Copy link
Contributor

chaadow commented Sep 13, 2022

Would you guys mind if I added an optional include_all_elements param which basically does not do the where used in this PR.because let's say we have an enum with 6 values :

  • I want to order by the first 3, and the rest I don't care about, but I still want them at the end of my relation.
  • With how it's done right now, it will never enter the ELSE case. because of the WHERE .. in (..)

@kddnewton kddnewton deleted the in-order-of-filter branch September 13, 2022 13:26
@gstokkink
Copy link

@chaadow did you get around creating a PR for that? I'd love to have that functionality as well.

@guigs
Copy link
Contributor

guigs commented Jun 30, 2023

@chaadow @gstokkink I was surprised by this behavior too. Here's what I'm using as a workaround:

in_order_of(:priority, %w[urgent high medium]).unscope(where: :priority)

@tiegz
Copy link
Contributor

tiegz commented Aug 25, 2023

I'm also curious if an option is in the works -- we're just upgrading to Rails 7.0 now and were surprised that an order predicate would limit rows returned.

@zavan
Copy link
Contributor

zavan commented Sep 28, 2023

I was also surprised by this behavior. @guigs workaround works, you just gotta be careful in case you have another (intentional) where on that column.

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

Successfully merging this pull request may close these issues.

None yet

8 participants