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: v1.90_01~334 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=771e7f6967f9026010eb24d8721facbe9473cb09;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 4a99414..4cc2c3a 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}||{}}