aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-07-30 09:24:28 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-07-30 09:24:28 -0700
commit19926cf6d3304b713ede84ae931e25700fd0db81 (patch)
treebb020c632cf934e43fcc8208a8bec759d7139128 /lib
parentb176daecddb81849c5db15472bd1b6847900e75c (diff)
downloadrails-19926cf6d3304b713ede84ae931e25700fd0db81.tar.gz
rails-19926cf6d3304b713ede84ae931e25700fd0db81.tar.bz2
rails-19926cf6d3304b713ede84ae931e25700fd0db81.zip
PERF: fewer objects, short circuit unless necessary
Diffstat (limited to 'lib')
-rw-r--r--lib/arel/algebra/relations/relation.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/arel/algebra/relations/relation.rb b/lib/arel/algebra/relations/relation.rb
index eeb5918f4b..97aa779926 100644
--- a/lib/arel/algebra/relations/relation.rb
+++ b/lib/arel/algebra/relations/relation.rb
@@ -38,8 +38,11 @@ module Arel
end
end
- def to_sql(formatter = Sql::SelectStatement.new(self))
- formatter.select compiler.select_sql, self
+ def to_sql(formatter = nil)
+ sql = compiler.select_sql
+
+ return sql unless formatter
+ formatter.select sql, self
end
def christener
@@ -76,7 +79,7 @@ module Arel
end
def from_clauses
- sources.blank? ? table_sql(Sql::TableReference.new(self)) : sources
+ sources.empty? ? table_sql : sources
end
def where_clauses