From: Matt S Trout Date: Mon, 25 Mar 2019 01:57:59 +0000 (+0000) Subject: andor now handled primarily by _expand_op X-Git-Tag: v1.90_01~337 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9194eb8ff91ed9f4320907502ac4ad3e166dc266;p=dbsrgits%2FSQL-Abstract.git andor now handled primarily by _expand_op --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 8d92a67..a8ccbb5 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -210,6 +210,8 @@ sub new { ] }; }), qw(ident value)), 'nest' => '_expand_nest', + (map +($_ => '_expand_andor'), + qw(and or)), }; $opt{render} = { @@ -695,12 +697,6 @@ sub _expand_expr_hashpair { ); return +{ -op => [ $op.' null', $self->_expand_ident(-ident => $k) ] }; } - if ($op =~ /^(and|or)$/) { - return $self->_expand_andor('-'.$op, [ - map +{ $k, { $_ => $vv->{$_} } }, - sort keys %$vv - ]); - } if (my $us = List::Util::first { $op =~ $_->{regex} } @{$self->{special_ops}}) { return { -op => [ $op, $self->_expand_ident(-ident => $k), $vv ] }; } @@ -826,8 +822,12 @@ sub _expand_bool { } sub _expand_andor { - my ($self, $k, $v) = @_; - my ($logop) = $k =~ /^-(.*)$/; + my ($self, $logic, $v, $k) = @_; + if (defined $k) { + $v = [ map +{ $k, { $_ => $v->{$_} } }, + sort keys %$v ]; + } + my ($logop) = $logic =~ /^-?(.*)$/; if (ref($v) eq 'HASH') { return +{ -op => [ $logop,