Permalink
Browse files

No need to create a new relation if the argument is blank.

  • Loading branch information...
1 parent 5191010 commit 33746c44cb3ace58507d5edc9833088524821d22 @miloops miloops committed Aug 25, 2009
Showing with 7 additions and 7 deletions.
  1. +6 −6 activerecord/lib/active_record/relation.rb
  2. +1 −1 arel
@@ -21,27 +21,27 @@ def first
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)
2 arel
Submodule arel updated 1 files
+26 −26 README.markdown

0 comments on commit 33746c4

Please sign in to comment.