diff options
author | Emilio Tagua <miloops@gmail.com> | 2010-06-20 15:51:49 -0300 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-06-21 01:10:33 +0200 |
commit | 7b7cedcb8d53110492e7d51405986f3e8e899fa4 (patch) | |
tree | f7d8e164f1547acd28233e084efbfdd8464c492c | |
parent | 756d77622b20d671605d097c029e0414987765d2 (diff) | |
download | rails-7b7cedcb8d53110492e7d51405986f3e8e899fa4.tar.gz rails-7b7cedcb8d53110492e7d51405986f3e8e899fa4.tar.bz2 rails-7b7cedcb8d53110492e7d51405986f3e8e899fa4.zip |
Don't waste time building relations if there are no values presents. [#4860 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 50e94134f5..60fa839df2 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -130,14 +130,14 @@ module ActiveRecord 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 @@ module ActiveRecord 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 |