From: Matt S Trout Date: Tue, 11 Sep 2018 23:14:43 +0000 (+0000) Subject: eliminate IS special op usage X-Git-Tag: v2.000000~3^2~484 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d686896caeb162229cf917871f599a504981c902;p=dbsrgits%2FSQL-Abstract.git eliminate IS special op usage --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index e932d99..4946b44 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -41,7 +41,7 @@ my @BUILTIN_SPECIAL_OPS = ( {regex => qr/^ (?: not \s )? in $/ix, handler => sub { die "NOPE" }}, {regex => qr/^ ident $/ix, handler => sub { die "NOPE" }}, {regex => qr/^ value $/ix, handler => sub { die "NOPE" }}, - {regex => qr/^ is (?: \s+ not )? $/ix, handler => '_where_field_IS'}, + {regex => qr/^ is (?: \s+ not )? $/ix, handler => sub { die "NOPE" }}, ); # unaryish operators - key maps to handler @@ -709,6 +709,17 @@ sub _expand_expr_hashpair { { -bind => [ $k, $vv ] } ] }; } + if ($vk =~ /^is(?:[ _]not)?$/) { + puke "$vk can only take undef as argument" + if defined($vv) + and not ( + ref($vv) eq 'HASH' + and exists($vv->{-value}) + and !defined($vv->{-value}) + ); + $vk =~ s/_/ /g; + return +{ -op => [ $vk.' null', { -ident => $k } ] }; + } } if (ref($v) eq 'ARRAY') { return $self->{sqlfalse} unless @$v;