Skip to content
Browse files

Don't waste time building relations if there are no values presents. [#…

…4860 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent 756d776 commit 7b7cedcb8d53110492e7d51405986f3e8e899fa4 @miloops miloops committed with josevalim Jun 20, 2010
Showing with 4 additions and 4 deletions.
  1. +4 −4 activerecord/lib/active_record/relation/query_methods.rb
View
8 activerecord/lib/active_record/relation/query_methods.rb
@@ -130,14 +130,14 @@ def build_arel
end
end
- arel = arel.having(*@having_values.uniq.select{|h| h.present?})
+ arel = arel.having(*@having_values.uniq.select{|h| h.present?}) if @having_values.present?
arel = arel.take(@limit_value) if @limit_value.present?
arel = arel.skip(@offset_value) if @offset_value.present?
- arel = arel.group(*@group_values.uniq.select{|g| g.present?})
+ arel = arel.group(*@group_values.uniq.select{|g| g.present?}) if @group_values.present?
- arel = arel.order(*@order_values.uniq.select{|o| o.present?}.map(&:to_s))
+ arel = arel.order(*@order_values.uniq.select{|o| o.present?}.map(&:to_s)) if @order_values.present?
selects = @select_values.uniq
@@ -150,7 +150,7 @@ def build_arel
arel = arel.project(@klass.quoted_table_name + '.*')
end
- arel = @from_value.present? ? arel.from(@from_value) : arel.from(@klass.quoted_table_name)
+ arel = arel.from(@from_value) if @from_value.present?
case @lock_value
when TrueClass

0 comments on commit 7b7cedc

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