diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-08-18 09:52:16 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-08-18 09:52:16 -0700 |
commit | e9a22ec1afa62ed6be75427315a3a650fc41e629 (patch) | |
tree | 2f9c88c19e114cb774620e4f2fb811eaf1d5f38d /lib/arel/visitors | |
parent | b69d3bfed823c6846a94d945a91d5a2551d47837 (diff) | |
download | rails-e9a22ec1afa62ed6be75427315a3a650fc41e629.tar.gz rails-e9a22ec1afa62ed6be75427315a3a650fc41e629.tar.bz2 rails-e9a22ec1afa62ed6be75427315a3a650fc41e629.zip |
fixing update support
Diffstat (limited to 'lib/arel/visitors')
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index 9dc7696ad8..fd467495ae 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -15,9 +15,7 @@ module Arel def visit_Arel_Nodes_UpdateStatement o [ "UPDATE #{visit o.relation}", - ("SET #{o.values.map { |column,value| - "#{quote_column_name(column.name)} = #{value ? quote(visit(value)) : 'NULL'}" - }.join ', '}" unless o.values.empty?), + ("SET #{o.values.map { |value| visit value }.join ', '}" unless o.values.empty?), ("WHERE #{o.wheres.map { |x| visit x }.join ' AND '}" unless o.wheres.empty?) ].compact.join ' ' end @@ -65,7 +63,13 @@ module Arel end def visit_Arel_Nodes_Equality o - "#{visit o.left} = #{quote visit o.right}" + right = o.right + right = right ? quote(visit(right)) : 'NULL' + "#{visit o.left} = #{right}" + end + + def visit_Arel_Nodes_UnqualifiedColumn o + "#{quote_column_name o.name}" end def visit_Arel_Attributes_Attribute o |