mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
parent
7e6996a1b3
commit
28c29973aa
2 changed files with 10 additions and 1 deletions
|
@ -56,7 +56,9 @@ module ActiveRecord
|
|||
|
||||
klass_scope =
|
||||
if klass.current_scope
|
||||
klass.current_scope.clone
|
||||
klass.current_scope.clone.tap { |scope|
|
||||
scope.joins_values = []
|
||||
}
|
||||
else
|
||||
relation = ActiveRecord::Relation.create(
|
||||
klass,
|
||||
|
|
|
@ -228,6 +228,13 @@ class RelationScopingTest < ActiveRecord::TestCase
|
|||
assert SpecialComment.all.any?
|
||||
end
|
||||
end
|
||||
|
||||
def test_circular_joins_with_current_scope_does_not_crash
|
||||
posts = Post.joins(comments: :post).scoping do
|
||||
Post.current_scope.first(10)
|
||||
end
|
||||
assert_equal posts, Post.joins(comments: :post).first(10)
|
||||
end
|
||||
end
|
||||
|
||||
class NestedRelationScopingTest < ActiveRecord::TestCase
|
||||
|
|
Loading…
Reference in a new issue