From: Peter Rabbitson Date: Fri, 17 Jan 2014 00:40:37 +0000 (+0100) Subject: Port tests and extra operator from master 40f2f231 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c8d97b3d74d77a885a62e1d6fc712b2b058dc4c7;p=dbsrgits%2FSQL-Abstract.git Port tests and extra operator from master 40f2f231 --- diff --git a/lib/SQL/Abstract/Converter.pm b/lib/SQL/Abstract/Converter.pm index 1bae6c3..c56c702 100644 --- a/lib/SQL/Abstract/Converter.pm +++ b/lib/SQL/Abstract/Converter.pm @@ -564,7 +564,11 @@ sub _where_hashpair_to_dq { if $op =~ $self->like_op or $op =~ $self->not_like_op; if ($op =~ $self->equality_op or $op =~ $self->like_op or $op eq 'IS') { 'IS NULL' - } elsif ($op =~ $self->inequality_op or $op =~ $self->not_like_op or $op eq 'IS NOT') { + } elsif ( + $op =~ $self->inequality_op or $op =~ $self->not_like_op + or + $op eq 'IS NOT' or $op eq 'NOT' + ) { 'IS NOT NULL' } else { die "Can't do undef -> NULL transform for operator ${op}"; diff --git a/t/01generate.t b/t/01generate.t index 8e7caf1..72bdd6c 100644 --- a/t/01generate.t +++ b/t/01generate.t @@ -608,6 +608,25 @@ my @tests = ( }, ); +# check is( not) => undef +for my $op ( qw(not is is_not), 'is not' ) { + (my $sop = uc $op) =~ s/_/ /gi; + + $sop = 'IS NOT' if $sop eq 'NOT'; + + for my $uc (0, 1) { + for my $prefix ('', '-') { + push @tests, { + func => 'where', + args => [{ a => { ($prefix . ($uc ? uc $op : lc $op) ) => undef } }], + stmt => "WHERE a $sop NULL", + stmt_q => "WHERE `a` $sop NULL", + bind => [], + }; + } + } +} + for my $t (@tests) { local $"=', ';