IS NOT? NULL support
[dbsrgits/SQL-Abstract-2.0-ish.git] / lib / SQL / Abstract / AST / v1.pm
index 0543330..e27584b 100644 (file)
@@ -246,6 +246,15 @@ class SQL::Abstract::AST::v1 extends SQL::Abstract {
     my ($lhs, $rhs) = @{$ast->{args}};
     my $op = $ast->{op};
 
+    # IS NOT? NULL
+    if ($rhs->{-type} eq 'value' && !defined $rhs->{value} &&
+        ($op eq '==' || $op eq '!='))
+    {
+      return $self->_expr($lhs) .
+             ($op eq '==' ? " IS " : " IS NOT ") .
+             "NULL";
+    }
+
     join (' ', $self->_expr($lhs), 
                $self->binop_mapping($op) || croak("Unknown binary operator $op"),
                $self->_expr($rhs)