Ticket #3438: eager_loading_order_fix.diff
| File eager_loading_order_fix.diff, 1.2 kB (added by coda.hale@gmail.com, 4 years ago) |
|---|
-
activerecord/lib/active_record/associations.rb
old new 1148 1148 add_limited_ids_condition!(sql, options, join_dependency) if !using_limitable_reflections?(join_dependency.reflections) && ((scope && scope[:limit]) || options[:limit]) 1149 1149 1150 1150 sql << "ORDER BY #{options[:order]} " if options[:order] 1151 1152 if options[:include] 1153 ordered_reflections = [] 1154 for association, reflection in reflections 1155 ordered_reflections << reflection if options[:include].include?(association) && reflection.options[:order] 1156 end 1157 if ordered_reflections.any? 1158 if options[:order] 1159 sql << ", " 1160 else 1161 sql << "ORDER BY " 1162 end 1163 sql << "#{ordered_reflections.map{ |r| r.options[:order] }.join(', ')} " if ordered_reflections.any? 1164 end 1165 end 1151 1166 1152 1167 add_limit!(sql, options, scope) if using_limitable_reflections?(join_dependency.reflections) 1153 1168