提交 a9c790e1 编写于 作者: P Pratik Naik

Simply methods for checking eager loaded tables references in the query

上级 4c5b5024
...@@ -1830,22 +1830,22 @@ def joined_tables(options) ...@@ -1830,22 +1830,22 @@ def joined_tables(options)
end end
# Checks if the conditions reference a table other than the current model table # Checks if the conditions reference a table other than the current model table
def include_eager_conditions?(options, tables = nil, joined_tables = nil) def include_eager_conditions?(options, joined_tables)
((tables || conditions_tables(options)) - (joined_tables || joined_tables(options))).any? (conditions_tables(options) - joined_tables).any?
end end
# Checks if the query order references a table other than the current model's table. # Checks if the query order references a table other than the current model's table.
def include_eager_order?(options, tables = nil, joined_tables = nil) def include_eager_order?(options, joined_tables)
((tables || order_tables(options)) - (joined_tables || joined_tables(options))).any? (order_tables(options) - joined_tables).any?
end end
def include_eager_select?(options, joined_tables = nil) def include_eager_select?(options, joined_tables)
(selects_tables(options) - (joined_tables || joined_tables(options))).any? (selects_tables(options) - joined_tables).any?
end end
def references_eager_loaded_tables?(options) def references_eager_loaded_tables?(options)
joined_tables = joined_tables(options) joined_tables = joined_tables(options)
include_eager_order?(options, nil, joined_tables) || include_eager_conditions?(options, nil, joined_tables) || include_eager_select?(options, joined_tables) include_eager_order?(options, joined_tables) || include_eager_conditions?(options, joined_tables) || include_eager_select?(options, joined_tables)
end end
def using_limitable_reflections?(reflections) def using_limitable_reflections?(reflections)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册