aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb23
1 files changed, 13 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index adc56fbef0..1e570a569b 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -137,16 +137,7 @@ module ActiveRecord
arel = arel.order(*@order_values.uniq.select{|o| o.present?}) if @order_values.present?
- selects = @select_values.uniq
-
- if selects.present?
- selects.each do |s|
- @implicit_readonly = false
- arel = arel.project(s) if s.present?
- end
- else
- arel = arel.project(@klass.quoted_table_name + '.*')
- end
+ arel = build_select(arel, @select_values.uniq)
arel = arel.from(@from_value) if @from_value.present?
@@ -219,6 +210,18 @@ module ActiveRecord
relation.join(custom_joins)
end
+ def build_select(arel, selects)
+ if selects.present?
+ @implicit_readonly = false
+ selects.each do |s|
+ arel = arel.project(s) if s.present?
+ end
+ else
+ arel = arel.project(@klass.quoted_table_name + '.*')
+ end
+ arel
+ end
+
def apply_modules(modules)
values = Array.wrap(modules)
@extensions += values if values.present?