From: Matt S Trout Date: Tue, 4 Sep 2018 02:53:32 +0000 (+0000) Subject: expand -bool, stop forbidding top-level unary ops X-Git-Tag: v1.90_01~480 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6ab1562a8be50f6953c30c66239a61e2b5e62322;p=dbsrgits%2FSQL-Abstract.git expand -bool, stop forbidding top-level unary ops --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 9364128..396fc83 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -556,6 +556,13 @@ sub _expand_expr_hashpair { if ($k eq '-nest') { return $self->_expand_expr($v); } + if ($k eq '-bool') { + if (ref($v)) { + return $self->_expand_expr($v); + } + puke "-bool => undef not supported" unless defined($v); + return { -ident => $v }; + } if (my ($rest) = $k =~/^-not[_ ](.*)$/) { return $self->_expand_expr({ -not => { "-${rest}", $v } }, $logic); } @@ -733,9 +740,10 @@ sub _where_unary_op { my ($self, $op, $rhs) = @_; # top level special ops are illegal in general - # this includes the -ident/-value ops (dual purpose unary and special) puke "Illegal use of top-level '-$op'" - if ! defined $self->{_nested_func_lhs} and List::Util::first { $op =~ $_->{regex} } @{$self->{special_ops}}; + if !(defined $self->{_nested_func_lhs}) + and List::Util::first { $op =~ $_->{regex} } @{$self->{special_ops}} + and not List::Util::first { $op =~ $_->{regex} } @{$self->{unary_ops}}; if (my $op_entry = List::Util::first { $op =~ $_->{regex} } @{$self->{unary_ops}}) { my $handler = $op_entry->{handler};