提交 3c101453 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #29129 from kamipo/prevent_extra_through_scope

Prevent extra `through_scope`
......@@ -11,6 +11,8 @@ def source_reflection
end
def associated_records_by_owner(preloader)
through_scope = through_scope()
preloader.preload(owners,
through_reflection.name,
through_scope)
......@@ -20,7 +22,7 @@ def associated_records_by_owner(preloader)
[owner, Array(center)]
end
reset_association owners, through_reflection.name
reset_association(owners, through_reflection.name, through_scope)
middle_records = through_records.flat_map(&:last)
......@@ -63,7 +65,7 @@ def id_to_index_map(ids)
id_map
end
def reset_association(owners, association_name)
def reset_association(owners, association_name, through_scope)
should_reset = (through_scope != through_reflection.klass.unscoped) ||
(options[:source_type] && through_reflection.collection?)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册