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

Merge pull request #25702 from k0kubun/joins-circular-reference

Remove circular join references in join_dependency
This commit is contained in:
Sean Griffin 2016-07-27 20:31:38 -04:00 committed by GitHub
commit a64d9835f1
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