diff options
Diffstat (limited to 'lib/arel/algebra/relations/relation.rb')
-rw-r--r-- | lib/arel/algebra/relations/relation.rb | 9 |
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 |