diff options
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index 554f98da14..ede43095ab 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -501,8 +501,13 @@ module Arel end def visit_Arel_Nodes_Assignment o, a - right = quote(o.right, column_for(o.left)) - "#{visit o.left, a} = #{right}" + case o.right + when Arel::Nodes::UnqualifiedColumn, Arel::Attributes::Attribute + "#{visit o.left, a} = #{visit o.right, a}" + else + right = quote(o.right, column_for(o.left)) + "#{visit o.left, a} = #{right}" + end end def visit_Arel_Nodes_Equality o, a |