提交 3fe9951f 编写于 作者: A Aaron Patterson

refactoring AST building

上级 f855090a
......@@ -217,13 +217,11 @@ def preload_has_and_belongs_to_many_association(records, reflection, preload_opt
associated_records_proxy.joins_values = [join]
associated_records_proxy.select_values = select
method = ids.length > 1 ? 'in' : 'eq'
all_associated_records = associated_records(ids) do |some_ids|
method = some_ids.length == 1 ? ['eq', some_ids.first] :
['in', some_ids]
conditions = right[reflection.primary_key_name].send(
method, some_ids.length == 1 ? some_ids.first : some_ids
)
conditions = right[reflection.primary_key_name].send(*method)
conditions = conditions.and(custom_conditions) unless custom_conditions.empty?
associated_records_proxy.where(conditions).to_a
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册