From: Matt S Trout Date: Mon, 25 Mar 2019 02:11:22 +0000 (+0000) Subject: switch ident/value to proposed unop style X-Git-Tag: v2.000000~3^2~355 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b45be6a7f369e287666e6e05c2132bdd54f6092b;p=dbsrgits%2FSQL-Abstract.git switch ident/value to proposed unop style --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index fb62c50..4e9eae0 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -187,8 +187,6 @@ sub new { $opt{expand_unary} = {}; $opt{expand} = { - -ident => '_expand_ident', - -value => '_expand_value', -not => '_expand_not', -bool => '_expand_bool', -and => '_expand_op_andor', @@ -201,19 +199,28 @@ sub new { 'not between' => '_expand_between', 'in' => '_expand_in', 'not in' => '_expand_in', - (map +($_ => sub { - my ($self, $op, $arg, $k) = @_; - return +{ -op => [ - $self->{cmp}, - $self->_expand_ident(-ident => $k), - $self->_expand_expr({ '-'.$op => $arg }), - ] }; - }), qw(ident value)), 'nest' => '_expand_nest', (map +($_ => '_expand_op_andor'), qw(and or)), }; + # placeholder for _expand_unop system + { + my %unops = (-ident => '_expand_ident', -value => '_expand_value'); + foreach my $name (keys %unops) { + $opt{expand}{$name} = $unops{$name}; + my ($op) = $name =~ /^-(.*)$/; + $opt{expand_op}{$op} = sub { + my ($self, $op, $arg, $k) = @_; + return +{ -op => [ + $self->{cmp}, + $self->_expand_ident(-ident => $k), + $self->_expand_expr({ '-'.$op => $arg }), + ] }; + }; + } + } + $opt{render} = { (map +("-$_", "_render_$_"), qw(op func bind ident literal list)), %{$opt{render}||{}}