diff options
-rw-r--r-- | lib/arel/visitors/dot.rb | 1 | ||||
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 4 | ||||
-rw-r--r-- | spec/arel/visitors/to_sql_spec.rb | 7 |
3 files changed, 11 insertions, 1 deletions
diff --git a/lib/arel/visitors/dot.rb b/lib/arel/visitors/dot.rb index ebbb211dd6..abf28968cf 100644 --- a/lib/arel/visitors/dot.rb +++ b/lib/arel/visitors/dot.rb @@ -94,6 +94,7 @@ module Arel alias :visit_Time :visit_String alias :visit_NilClass :visit_String alias :visit_TrueClass :visit_String + alias :visit_FalseClass :visit_String alias :visit_Arel_SqlLiteral :visit_String alias :visit_Fixnum :visit_String alias :visit_Symbol :visit_String diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index 093deedee5..f70cae9430 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -151,7 +151,8 @@ module Arel def visit_Arel_Nodes_Equality o right = o.right - right = right ? visit(right) : 'NULL' + # FIXME: maybe we should visit NilClass? + right = right.nil? ? 'NULL' : visit(right) "#{visit o.left} = #{right}" end @@ -179,6 +180,7 @@ module Arel def visit_DateTime o; quote(o) end def visit_Float o; quote(o) end def visit_BigDecimal o; quote(o) end + def visit_FalseClass o; quote(o) end DISPATCH = {} def visit object diff --git a/spec/arel/visitors/to_sql_spec.rb b/spec/arel/visitors/to_sql_spec.rb index ed8487c6eb..f8327b02f6 100644 --- a/spec/arel/visitors/to_sql_spec.rb +++ b/spec/arel/visitors/to_sql_spec.rb @@ -8,6 +8,13 @@ module Arel @attr = Table.new(:users)[:id] end + describe 'equality' do + it 'should handle false' do + sql = @visitor.accept Nodes::Equality.new(false, false) + sql.should be_like %{ 'f' = 'f' } + end + end + it "should visit_DateTime" do @visitor.accept DateTime.now end |