aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-07-30 10:02:34 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-07-30 10:02:34 -0700
commitd22b2169f7151d076b06bfa5da85dbe5497d8ea4 (patch)
treedd8802c35f62eee53d0af09c67751beaa3746d69
parent19926cf6d3304b713ede84ae931e25700fd0db81 (diff)
downloadrails-d22b2169f7151d076b06bfa5da85dbe5497d8ea4.tar.gz
rails-d22b2169f7151d076b06bfa5da85dbe5497d8ea4.tar.bz2
rails-d22b2169f7151d076b06bfa5da85dbe5497d8ea4.zip
PERF: where is only ever called with 0 or 1 arguments. eliminate *args
-rw-r--r--lib/arel/algebra/relations/relation.rb6
-rw-r--r--lib/arel/engines/sql/relations/compiler.rb2
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/arel/algebra/relations/relation.rb b/lib/arel/algebra/relations/relation.rb
index 97aa779926..0441b14382 100644
--- a/lib/arel/algebra/relations/relation.rb
+++ b/lib/arel/algebra/relations/relation.rb
@@ -126,7 +126,7 @@ module Arel
end
%w{
- having group order where project
+ having group order project
}.each do |op|
class_eval <<-OPERATION, __FILE__, __LINE__
def #{op}(*args)
@@ -135,6 +135,10 @@ module Arel
OPERATION
end
+ def where clause = nil
+ clause ? Where.new(self, [clause]) : self
+ end
+
def skip thing = nil
thing ? Skip.new(self, thing) : self
end
diff --git a/lib/arel/engines/sql/relations/compiler.rb b/lib/arel/engines/sql/relations/compiler.rb
index 43d0e1aeb9..c8511374d9 100644
--- a/lib/arel/engines/sql/relations/compiler.rb
+++ b/lib/arel/engines/sql/relations/compiler.rb
@@ -14,7 +14,7 @@ module Arel
def select_sql
projections = @relation.projections
- if projections.first.is_a?(Count) && projections.size == 1 &&
+ if Count === projections.first && projections.size == 1 &&
(relation.taken.present? || relation.wheres.present?) && relation.joins(self).blank?
subquery = [
"SELECT 1 FROM #{relation.from_clauses}", build_clauses