[Fix #54591] Raise an error in order dependent finder methods when the model has no order columns
Motivation / Background
Fixes https://github.com/rails/rails/issues/54591 Follow-up to https://github.com/rails/rails/pull/54607
Detail
- Adds a new error
ActiveRecord::MissingRequiredOrderErrorwhich gets raised inActiveRecord::FinderMethods#ordered_relation(used by#lastand and allfind_nth*methods) when there are noorder_valuesand no order columns to be used for the default order. - Updates a similar case where
ActiveRecord::IrreversibleOrderErroris raised inActiveRecord::QueryMethods#reverse_sql_orderto have a message consistent with this new error.
cc @byroot
Checklist
Before submitting the PR make sure the following are checked:
- [x] This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
- [x] Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex:
[Fix #issue-number] - [x] Tests are added or updated if you fix a bug or add a feature.
- [x] CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.
I wonder if this should be considered breaking enough to warrant a framework default and a deprecation.
Which is debatable because this is solving a bug, but prior you'd get a somewhat unpredictable behavior but "working" behavior, now you'd get a straight error.
I wonder if this should be considered breaking enough to warrant a framework default and a deprecation.
Which is debatable because this is solving a bug, but prior you'd get a somewhat unpredictable behavior but "working" behavior, now you'd get a straight error.
Hmm, yeah, that's a good point, I can see the argument for a deprecation notice. I will action soon 👍🏽
I wonder if this should be considered breaking enough to warrant a framework default and a deprecation. Which is debatable because this is solving a bug, but prior you'd get a somewhat unpredictable behavior but "working" behavior, now you'd get a straight error.
Hmm, yeah, that's a good point, I can see the argument for a deprecation notice. I will action soon 👍🏽
Action-ed! Hopefully I've done all the things right...
Uh, just realized this fell through the cracks, I'll try to rebase it.
Thank you!