From 3d8ccb924084ecd341b2d9644e6e0b66903d8432 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Thu, 24 Jun 2010 20:36:01 -0300 Subject: Makes a build_select for the select part of build_arel --- .../lib/active_record/relation/query_methods.rb | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'activerecord') 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? -- cgit v1.2.3