提交 e170d34a 编写于 作者: A Antonio Cangiano 提交者: Jeremy Kemper

Fixed non-standard SQL generated by preloading has_and_belongs_to_many association

上级 e6c1f46e
...@@ -103,10 +103,10 @@ def preload_has_and_belongs_to_many_association(records, reflection, preload_opt ...@@ -103,10 +103,10 @@ def preload_has_and_belongs_to_many_association(records, reflection, preload_opt
associated_records = reflection.klass.find(:all, :conditions => [conditions, ids], associated_records = reflection.klass.find(:all, :conditions => [conditions, ids],
:include => options[:include], :include => options[:include],
:joins => "INNER JOIN #{connection.quote_table_name options[:join_table]} as t0 ON #{reflection.klass.quoted_table_name}.#{reflection.klass.primary_key} = t0.#{reflection.association_foreign_key}", :joins => "INNER JOIN #{connection.quote_table_name options[:join_table]} as t0 ON #{reflection.klass.quoted_table_name}.#{reflection.klass.primary_key} = t0.#{reflection.association_foreign_key}",
:select => "#{options[:select] || table_name+'.*'}, t0.#{reflection.primary_key_name} as _parent_record_id", :select => "#{options[:select] || table_name+'.*'}, t0.#{reflection.primary_key_name} as the_parent_record_id",
:order => options[:order]) :order => options[:order])
set_association_collection_records(id_to_record_map, reflection.name, associated_records, '_parent_record_id') set_association_collection_records(id_to_record_map, reflection.name, associated_records, 'the_parent_record_id')
end end
def preload_has_one_association(records, reflection, preload_options={}) def preload_has_one_association(records, reflection, preload_options={})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册