Deprecate delegating to `arel` in `Relation` #29619
Merged
Conversation
activerecord/lib/active_record/relation/delegation.rb
Outdated
@@ -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." |
kaspth
Jun 29, 2017
Member
Isn't arel
still private API? So the delegation makes sense?
Isn't arel
still private API? So the delegation makes sense?
rafaelfranca
Jun 29, 2017
Member
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
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 79f71d3...b06f64c). But a relation still could respond to the method because `arel` also have the same named method (#28976). Removing the delegation will achieve predictable behavior.
d9fca84
Great! |
Thanks! |
kamipo
added a commit
to kamipo/rails
that referenced
this pull request
Jul 1, 2017
kamipo
added a commit
that referenced
this pull request
Aug 27, 2017
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! |
koic
added a commit
to koic/24pullrequests
that referenced
this pull request
Sep 5, 2018
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)
andrew
added a commit
to 24pullrequests/24pullrequests
that referenced
this pull request
Sep 5, 2018
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)
tigefa4u
pushed a commit
to tigefa4u/gitlabhq
that referenced
this pull request
Aug 16, 2019
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
tigefa4u
pushed a commit
to tigefa4u/gitlabhq
that referenced
this pull request
Aug 21, 2019
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
tigefa4u
pushed a commit
to tigefa4u/gitlabhq
that referenced
this pull request
Aug 26, 2019
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
jmartin-r7
added a commit
to jmartin-r7/metasploit-credential
that referenced
this pull request
Apr 24, 2020
Delegate directly to Arel to remove Rails 5 deprecation. See: rails/rails#29619
jmartin-r7
added a commit
to jmartin-r7/metasploit-credential
that referenced
this pull request
Apr 24, 2020
Delegate directly to Arel to remove Rails 5 deprecation. See: rails/rails#29619
arvados-bot
pushed a commit
to arvados/arvados
that referenced
this pull request
Aug 17, 2020
Explained at: rails/rails#29619 (comment) Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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.