Restore the ability to pass Active Record objects to update_all
#25876
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.
The ability to do this was mostly unintentional, and relied on other code which
is slated to be deprecated soon. In 5.0.0 attempting to pass an Active
Record object to
update_all
will cast it tonil
instead of grabbingthe ID. This is because we are going through
Type#serialize
sooner inthe stack, and not hitting the
quoted_id
call in the connectionadapter. This mirrors the behavior that would occur if you attempted to
assign the record to the foreign key.
While this behavior wasn't really intentional, it was a breaking change
that I didn't intend to make without deprecation. The behavior is
restored, but immediately deprecated. While this does introduce a
deprecation warning in a patch release, it deprecates behavior that was
not working in the last major, so no working code could have been
relying on it.
The implementation checks for
Base
explicitly instead of objects whichrespond to
quoted_id
to avoid collisions with any other code whichoverrides
quoted_id
. I'd like to deprecatequoted_id
entirely in thenext release.