Skip to content
  • Sean Griffin's avatar
    7c106aef
    Restore the ability to pass Active Record objects to `update_all` · 7c106aef
    Sean Griffin authored
    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 to `nil` instead of grabbing
    the ID. This is because we are going through `Type#serialize` sooner in
    the stack, and not hitting the `quoted_id` call in the connection
    adapter. 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 which
    respond to `quoted_id` to avoid collisions with any other code which
    overrides `quoted_id`. I'd like to deprecate `quoted_id` entirely in the
    next release.
    7c106aef
    Restore the ability to pass Active Record objects to `update_all`
    Sean Griffin authored
    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 to `nil` instead of grabbing
    the ID. This is because we are going through `Type#serialize` sooner in
    the stack, and not hitting the `quoted_id` call in the connection
    adapter. 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 which
    respond to `quoted_id` to avoid collisions with any other code which
    overrides `quoted_id`. I'd like to deprecate `quoted_id` entirely in the
    next release.
Loading