-
Jean Boussier authored
In https://github.com/rails/rails/pull/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 https://github.com/rails/rails/pull/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.
Jean Boussier authoredIn https://github.com/rails/rails/pull/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 https://github.com/rails/rails/pull/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.
Loading