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

Make the Relation -> Model delegation stricter #50396

Merged
merged 1 commit into from
May 28, 2024

Commits on May 28, 2024

  1. Make the Relation -> Model delegation stricter

    In rails#50395 I noticed lots of
    methods are delegated from `Relation` to the model. The intent of
    this code is to allow using use defined class methods like scopes.
    
    But because of this autmated delegation it allows calling any
    `ActiveRecord::Base` class method on a `Relation`, which in itself
    may be desireable, however we very wastefully define the delegator
    on the first call, and worse we wrap it with a global scope setter.
    
    This also has led to bugs in the past, like rails#51776
    
    So I think we should be more strict about it.
    
    We can't deprecate this behavior because gems might depend on it, however we
    can ban it from Active Record's own test suite to avoid regressions.
    byroot committed May 28, 2024
    Configuration menu
    Copy the full SHA
    fd5bd98 View commit details
    Browse the repository at this point in the history