Ignore orders for delete_all/update_all queries. #621
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
- What is it good for
While upgrading an application from Rails 5.2 to 6.1 (CPK 11.2 -> 13.0) some specs broke. I tracked it down to
Entity.delete_all
calls on the setup of the test suite. Then I found the broken SQL statement and about an syntax error near toORDER
- there is nothing to order at the top-level forDELETE
andUPDATE
queries. This is caused by adefault_scope { order(created_at: :asc) }
.Click for Details
ActiveRecord::Base.delete_all
ActiveRecord::Base.update_all
- What I did
Just removed the ordering on
delete_all
andupdate_all
SQL statement assembly and added tests for it. I fixed the issue at thear_6.1.x
branch, but I'm sure this must be ported back to 6.0 and master.- A picture of a cute animal (not mandatory but encouraged)