aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/scoping/named.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-02-15 11:34:54 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-02-15 17:40:15 +0900
commit4c6171d6056a346a953792a954853d14c000dc90 (patch)
tree6828ab3c21482a8a81bc0c9229e2028e9e26bdc0 /activerecord/lib/active_record/scoping/named.rb
parentcdb8697b4a654aad2e65590d58c5f581a53d6b33 (diff)
downloadrails-4c6171d6056a346a953792a954853d14c000dc90.tar.gz
rails-4c6171d6056a346a953792a954853d14c000dc90.tar.bz2
rails-4c6171d6056a346a953792a954853d14c000dc90.zip
Deprecate using class level querying methods if the receiver scope regarded as leaked
This deprecates using class level querying methods if the receiver scope regarded as leaked, since #32380 and #35186 may cause that silently leaking information when people upgrade the app. We need deprecation first before making those.
Diffstat (limited to 'activerecord/lib/active_record/scoping/named.rb')
-rw-r--r--activerecord/lib/active_record/scoping/named.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/scoping/named.rb b/activerecord/lib/active_record/scoping/named.rb
index 5278eb29a9..681a5c6250 100644
--- a/activerecord/lib/active_record/scoping/named.rb
+++ b/activerecord/lib/active_record/scoping/named.rb
@@ -27,6 +27,14 @@ module ActiveRecord
scope = current_scope
if scope
+ if scope._deprecated_scope_source
+ ActiveSupport::Deprecation.warn(<<~MSG.squish)
+ Class level methods will no longer inherit scoping from `#{scope._deprecated_scope_source}`
+ in Rails 6.1. To continue using the scoped relation, pass it into the block directly.
+ To instead access the full set of models, as Rails 6.1 will, use `#{name}.unscoped`.
+ MSG
+ end
+
if self == scope.klass
scope.clone
else
@@ -180,7 +188,7 @@ module ActiveRecord
if body.respond_to?(:to_proc)
singleton_class.define_method(name) do |*args|
- scope = all._exec_scope(*args, &body)
+ scope = all._exec_scope(name, *args, &body)
scope = scope.extending(extension) if extension
scope
end