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: v2.000000~3^2~501 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a9aff1789cf42f54767206976166da139a4f42b2;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 51ec3a2..ac27c42 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};