From: Matt S Trout Date: Sun, 16 Sep 2018 22:45:12 +0000 (+0000) Subject: eliminate (I think) -not as an expanded node type X-Git-Tag: v2.000000~3^2~477 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0fa721c96d6c01cf049e60a0e2b322b2aaf57ac9;p=dbsrgits%2FSQL-Abstract.git eliminate (I think) -not as an expanded node type --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index ac4e80c..234ac75 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -617,12 +617,13 @@ sub _expand_expr_hashpair { return { -ident => $v }; } if ($k eq '-not') { - return { -not => $self->_expand_expr($v) }; + return { -op => [ 'not', $self->_expand_expr($v) ] }; } if (my ($rest) = $k =~/^-not[_ ](.*)$/) { - return +{ -not => + return +{ -op => [ + 'not', $self->_expand_expr_hashpair("-${rest}", $v, $logic) - }; + ] }; } if (my ($logic) = $k =~ /^-(and|or)$/i) { if (ref($v) eq 'HASH') { @@ -1284,7 +1285,7 @@ sub _where_op_OP { ? "${expr_sql} ${op_sql}" : "${op_sql} ${expr_sql}" ); - return ($final_sql, @bind); + return (($op eq 'not' ? '('.$final_sql.')' : $final_sql), @bind); } elsif (@args == 2) { my ($l, $r) = map [ $self->_recurse_where($_) ], @args; return (