Browse files

Makes a build_select for the select part of build_arel

  • Loading branch information...
1 parent 82dc16b commit 3d8ccb924084ecd341b2d9644e6e0b66903d8432 @spastorino spastorino committed Jun 24, 2010
Showing with 13 additions and 10 deletions.
  1. +13 −10 activerecord/lib/active_record/relation/query_methods.rb
View
23 activerecord/lib/active_record/relation/query_methods.rb
@@ -137,16 +137,7 @@ def build_arel
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 @@ def build_joins(relation, joins)
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?

0 comments on commit 3d8ccb9

Please sign in to comment.