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)
use strict;
use warnings;
-use Test::More tests => 14;
+use Test::More tests => 16;
use Test::Differences;
use_ok('SQL::Abstract') or BAIL_OUT( "$@" );
}
), "me.id LIKE ?",
"LIKE expr clause";
+
+
+is $sqla->dispatch(
+ { -type => 'expr',
+ op => '==',
+ args => [
+ {-type => name => args => [qw/me id/] },
+ { -type => 'value', value => undef }
+ ]
+ }
+), "me.id IS NULL",
+ "== undef";
+
+
+is $sqla->dispatch(
+ { -type => 'expr',
+ op => '!=',
+ args => [
+ {-type => name => args => [qw/me id/] },
+ { -type => 'value', value => undef }
+ ]
+ }
+), "me.id IS NOT NULL",
+ "!= undef";