lib/arel/engines/sql/formatters.rb in arel-0.1.0 vs lib/arel/engines/sql/formatters.rb in arel-0.1.2
- old
+ new
@@ -11,11 +11,10 @@
end
end
class SelectClause < Formatter
def attribute(attribute)
- # FIXME this should check that the column exists
"#{quote_table_name(name_for(attribute.original_relation))}.#{quote_column_name(attribute.name)}" +
(attribute.alias ? " AS #{quote(attribute.alias.to_s)}" : "")
end
def expression(expression)
@@ -90,11 +89,15 @@
def select(select_sql, table)
"(#{select_sql}) AS #{quote_table_name(name_for(table))}"
end
def table(table)
- quote_table_name(table.name) +
- (table.name != name_for(table) ? " AS " + quote_table_name(name_for(table)) : '')
+ if table.name =~ /\s/
+ table.name
+ else
+ quote_table_name(table.name) +
+ (table.name != name_for(table) ? " AS " + quote_table_name(name_for(table)) : '')
+ end
end
end
class Attribute < WhereCondition
def scalar(scalar)