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 | |
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.
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 12 | ||||
m--------- | arel | 10 |
2 files changed, 11 insertions, 11 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) diff --git a/arel b/arel -Subproject 3d747a56b76ae97645dd265cc75e73e5f782719 +Subproject 755a7ced2f98b0bb246089c80cdfa04cd918fa8 |