From 5e4bfb1ce4144785feaeffc6210740e3e4ce5770 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 28 Apr 2009 19:51:00 -0300 Subject: Workaround so quote_table_name is not included when not using a column name. For example: project('2 * amount') --- lib/arel/sql/formatters.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/arel') diff --git a/lib/arel/sql/formatters.rb b/lib/arel/sql/formatters.rb index 22a116117e..f105fbea72 100644 --- a/lib/arel/sql/formatters.rb +++ b/lib/arel/sql/formatters.rb @@ -13,7 +13,12 @@ module Arel class SelectClause < Formatter def attribute(attribute) + # FIXME this should check that the column exists + if attribute.name.to_s =~ /^\w*$/ "#{quote_table_name(name_for(attribute.original_relation))}.#{quote_column_name(attribute.name)}" + (attribute.alias ? " AS #{quote(attribute.alias.to_s)}" : "") + else + attribute.name.to_s + (attribute.alias ? " AS #{quote(attribute.alias.to_s)}" : "") + end end def expression(expression) -- cgit v1.2.3