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
Deprecate delegating to arel
in Relation
#29619
Deprecate delegating to arel
in Relation
#29619
Conversation
@@ -89,6 +89,9 @@ def method_missing(method, *args, &block) | |||
self.class.delegate_to_scoped_klass(method) | |||
scoping { @klass.public_send(method, *args, &block) } | |||
elsif arel.respond_to?(method) | |||
ActiveSupport::Deprecation.warn \ | |||
"Delegating #{method} to arel is deprecated and will be removed in Rails 5.3. " \ | |||
"Use relation.arel.#{method} instead." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't arel
still private API? So the delegation makes sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. Better to say that is going to be removed with no replacement. Also the next version of Rails after 5.2 is 6.0
Active Record doesn't rely delegating to `arel` in the internal since 425f2ca. The delegation is a lower priority than delegating to `klass`, so it is pretty unclear which method is delegated to `arel`. For example, `bind_values` method was removed at b06f64c (a series of changes rails/rails@79f71d3...b06f64c). But a relation still could respond to the method because `arel` also have the same named method (rails#28976). Removing the delegation will achieve predictable behavior.
848419d
to
d9fca84
Compare
Great! |
Thanks! |
Not sure if this is the right place for this question, but I'm unsure how to move this to non-deprecated calls (short of manually generating SQL):
This generates SQL like this:
But gives this deprecation warning:
|
Please use |
@kamipo Thanks! |
This commit suppresses the following Active Record warnings. ```console DEPRECATION WARNING: Delegating exists to arel is deprecated and will be removed in Rails 6.0. (called from pull_request_filter at /Users/koic/src/github.com/24pullrequests/24pullrequests/app/models/aggregation_filter.rb:7) DEPRECATION WARNING: Delegating with to arel is deprecated and will be removed in Rails 6.0. (called from block (4 levels) in <top (required)> at /Users/koic/src/github.com/24pullrequests/24pullrequests/spec/controllers/users_controller_spec.rb:16) ``` This patch is based on the following comment. rails/rails#29619 (comment)
This commit suppresses the following Active Record warnings. ```console DEPRECATION WARNING: Delegating exists to arel is deprecated and will be removed in Rails 6.0. (called from pull_request_filter at /Users/koic/src/github.com/24pullrequests/24pullrequests/app/models/aggregation_filter.rb:7) DEPRECATION WARNING: Delegating with to arel is deprecated and will be removed in Rails 6.0. (called from block (4 levels) in <top (required)> at /Users/koic/src/github.com/24pullrequests/24pullrequests/spec/controllers/users_controller_spec.rb:16) ``` This patch is based on the following comment. rails/rails#29619 (comment)
As mentioned in rails/rails#29619, this removes this warning message: ``` Delegating join_sources to arel is deprecated and will be removed in Rails 6.0. (called from project_clusters_base_query at app/models/clusters/clusters_hierarchy.rb:62) ``` Part of https://gitlab.com/gitlab-org/gitlab-ce/issues/61451
As mentioned in rails/rails#29619, this removes this warning message: ``` Delegating join_sources to arel is deprecated and will be removed in Rails 6.0. (called from project_clusters_base_query at app/models/clusters/clusters_hierarchy.rb:62) ``` Part of https://gitlab.com/gitlab-org/gitlab-ce/issues/61451
As mentioned in rails/rails#29619, this removes this warning message: ``` Delegating join_sources to arel is deprecated and will be removed in Rails 6.0. (called from project_clusters_base_query at app/models/clusters/clusters_hierarchy.rb:62) ``` Part of https://gitlab.com/gitlab-org/gitlab-ce/issues/61451
Delegate directly to Arel to remove Rails 5 deprecation. See: rails/rails#29619
Delegate directly to Arel to remove Rails 5 deprecation. See: rails/rails#29619
Explained at: rails/rails#29619 (comment) Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>
Active Record doesn't rely delegating to
arel
in the internal since425f2ca. The delegation is a lower priority than delegating to
klass
,so it is pretty unclear which method is delegated to
arel
.For example,
bind_values
method was removed at b06f64c (a series ofchanges 79f71d3...b06f64c). But a
relation still could respond to the method because
arel
also have thesame named method (#28976).
Removing the delegation will achieve predictable behavior.