diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-04-28 19:51:00 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-04-28 19:51:00 -0300 |
commit | 5e4bfb1ce4144785feaeffc6210740e3e4ce5770 (patch) | |
tree | f012f0c84f07d4eddfda79a52640fa5922eff880 /lib | |
parent | 1dfae3a5a01b05bf14de88958b625b865748387b (diff) | |
download | rails-5e4bfb1ce4144785feaeffc6210740e3e4ce5770.tar.gz rails-5e4bfb1ce4144785feaeffc6210740e3e4ce5770.tar.bz2 rails-5e4bfb1ce4144785feaeffc6210740e3e4ce5770.zip |
Workaround so quote_table_name is not included when not using a column name. For example: project('2 * amount')
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arel/sql/formatters.rb | 5 |
1 files changed, 5 insertions, 0 deletions
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) |