From d1c53a9ad273f31618adcfbcabb39fd74bb2b91f Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 30 Jul 2010 13:38:09 -0700 Subject: reducing function calls and using faster methods for testing --- activerecord/lib/active_record/relation/query_methods.rb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'activerecord/lib/active_record/relation/query_methods.rb') diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 716e7275a5..4342dde5c8 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -129,7 +129,7 @@ module ActiveRecord def build_arel arel = table - arel = build_joins(arel, @joins_values) if @joins_values.present? + arel = build_joins(arel, @joins_values) unless @joins_values.empty? @where_values.uniq.each do |where| next if where.blank? @@ -145,7 +145,7 @@ module ActiveRecord 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.take(@limit_value) if @limit_value arel = arel.skip(@offset_value) if @offset_value.present? arel = arel.group(*@group_values.uniq.select{|g| g.present?}) if @group_values.present? @@ -155,13 +155,7 @@ module ActiveRecord arel = build_select(arel, @select_values.uniq) arel = arel.from(@from_value) if @from_value.present? - - case @lock_value - when TrueClass - arel = arel.lock - when String - arel = arel.lock(@lock_value) - end if @lock_value.present? + arel = arel.lock(@lock_value) if @lock_value arel end -- cgit v1.2.3