diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-08-25 19:47:29 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-08-25 19:47:29 -0300 |
commit | 33746c44cb3ace58507d5edc9833088524821d22 (patch) | |
tree | 81478e7a016a04d5753876dacdb437bff74d1e48 /activerecord/lib | |
parent | 51910106f196e4461b35661f90a835dec0c21ccf (diff) | |
download | rails-33746c44cb3ace58507d5edc9833088524821d22.tar.gz rails-33746c44cb3ace58507d5edc9833088524821d22.tar.bz2 rails-33746c44cb3ace58507d5edc9833088524821d22.zip |
No need to create a new relation if the argument is blank.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index b69a12bc7b..570ba3f80d 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -21,27 +21,27 @@ module ActiveRecord end def select(selects) - Relation.new(@klass, @relation.project(selects)) + selects.blank? ? self : Relation.new(@klass, @relation.project(selects)) end def group(groups) - Relation.new(@klass, @relation.group(groups)) + groups.blank? ? self : Relation.new(@klass, @relation.group(groups)) end def order(orders) - Relation.new(@klass, @relation.order(orders)) + orders.blank? ? self : Relation.new(@klass, @relation.order(orders)) end def limit(limits) - Relation.new(@klass, @relation.take(limits)) + limits.blank? ? self : Relation.new(@klass, @relation.take(limits)) end def offset(offsets) - Relation.new(@klass, @relation.skip(offsets)) + offsets.blank? ? self : Relation.new(@klass, @relation.skip(offsets)) end def on(join) - Relation.new(@klass, @relation.on(join)) + join.blank? ? self : Relation.new(@klass, @relation.on(join)) end def joins(join, join_type = nil) |