diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-10 13:36:42 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-10 13:36:42 -0700 |
commit | 1ba8ac0848f40c7fa18c9e7bdac944a50d3c348c (patch) | |
tree | c5dfd0c9a4058da6e8310340c612b9d15deca36b /lib/arel/visitors | |
parent | e06061089735b34ac10465684db5a08d90623469 (diff) | |
download | rails-1ba8ac0848f40c7fa18c9e7bdac944a50d3c348c.tar.gz rails-1ba8ac0848f40c7fa18c9e7bdac944a50d3c348c.tar.bz2 rails-1ba8ac0848f40c7fa18c9e7bdac944a50d3c348c.zip |
differentiating equality and assignment
Diffstat (limited to 'lib/arel/visitors')
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index f70cae9430..8638bf43c3 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -149,13 +149,24 @@ module Arel "#{visit o.left} OR #{visit o.right}" end - def visit_Arel_Nodes_Equality o + def visit_Arel_Nodes_Assignment o right = o.right - # FIXME: maybe we should visit NilClass? + right = right.nil? ? 'NULL' : visit(right) "#{visit o.left} = #{right}" end + def visit_Arel_Nodes_Equality o + right = o.right + + # FIXME: maybe we should visit NilClass? + if right.nil? + "#{visit o.left} IS NULL" + else + "#{visit o.left} = #{visit right}" + end + end + def visit_Arel_Nodes_UnqualifiedColumn o "#{quote_column_name o.name}" end |