1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Remove circular join references in join_dependency

Fixes #25653.
This commit is contained in:
Takashi Kokubun 2016-07-06 00:30:50 +09:00
parent 7e6996a1b3
commit 28c29973aa
2 changed files with 10 additions and 1 deletions

View file

@ -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,

View file

@ -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