提交 c107849a 编写于 作者: A Aaron Patterson

reduce objects, reduce loops and function calls while building the conditional

上级 f3a5995b
......@@ -385,7 +385,7 @@ def find_associated_records(ids, reflection, preload_options)
conditions << table["#{interface}_type"].eq(base_class.sti_name)
end
conditions += append_conditions(reflection, preload_options)
conditions.concat append_conditions(reflection, preload_options)
find_options = {
:select => preload_options[:select] || options[:select] || table[Arel.star],
......@@ -397,9 +397,7 @@ def find_associated_records(ids, reflection, preload_options)
associated_records(ids) do |some_ids|
method = in_or_equal(some_ids)
where = conditions.inject(table[key].send(*method)) do |ast, cond|
ast.and cond
end
where = table.create_and(conditions + [table[key].send(*method)])
reflection.klass.scoped.apply_finder_options(find_options.merge(:conditions => where)).to_a
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册