Skip to content
This repository

Showing 1 changed file with 13 additions and 10 deletions. Show diff stats Hide diff stats

  1. +13 10 activerecord/lib/active_record/relation/query_methods.rb
23 activerecord/lib/active_record/relation/query_methods.rb
@@ -137,16 +137,7 @@ def build_arel
137 137
138 138 arel = arel.order(*@order_values.uniq.select{|o| o.present?}) if @order_values.present?
139 139
140   - selects = @select_values.uniq
141   -
142   - if selects.present?
143   - selects.each do |s|
144   - @implicit_readonly = false
145   - arel = arel.project(s) if s.present?
146   - end
147   - else
148   - arel = arel.project(@klass.quoted_table_name + '.*')
149   - end
  140 + arel = build_select(arel, @select_values.uniq)
150 141
151 142 arel = arel.from(@from_value) if @from_value.present?
152 143
@@ -219,6 +210,18 @@ def build_joins(relation, joins)
219 210 relation.join(custom_joins)
220 211 end
221 212
  213 + def build_select(arel, selects)
  214 + if selects.present?
  215 + @implicit_readonly = false
  216 + selects.each do |s|
  217 + arel = arel.project(s) if s.present?
  218 + end
  219 + else
  220 + arel = arel.project(@klass.quoted_table_name + '.*')
  221 + end
  222 + arel
  223 + end
  224 +
222 225 def apply_modules(modules)
223 226 values = Array.wrap(modules)
224 227 @extensions += values if values.present?

0 comments on commit 3d8ccb9

Please sign in to comment.
Something went wrong with that request. Please try again.