From: Matt S Trout Date: Mon, 1 Apr 2019 04:16:09 +0000 (+0000) Subject: clean up row and op expansion to methods X-Git-Tag: v2.000000~3^2~294 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=63143f96ce1fe73300e2f2bf9de6cc13803c4bcd;p=dbsrgits%2FSQL-Abstract.git clean up row and op expansion to methods --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index acadcaf..eab0be1 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -201,17 +201,10 @@ sub new { -bind => sub { shift; +{ @_ } }, -in => '_expand_in', -not_in => '_expand_in', - -row => sub { - my ($self, $node, $args) = @_; - +{ $node => [ map $self->expand_expr($_), @$args ] }; - }, + -row => '_expand_row', -between => '_expand_between', -not_between => '_expand_between', - -op => sub { - my ($self, $node, $args) = @_; - my ($op, @opargs) = @$args; - +{ $node => [ $op, map $self->expand_expr($_), @opargs ] }; - }, + -op => '_expand_op', (map +($_ => '_expand_op_is'), ('-is', '-is_not')), -ident => '_expand_ident', -value => '_expand_value', @@ -910,6 +903,17 @@ sub _expand_not { +{ -op => [ 'not', $_[0]->_expand_expr($_[2]) ] }; } +sub _expand_row { + my ($self, $node, $args) = @_; + +{ $node => [ map $self->expand_expr($_), @$args ] }; +} + +sub _expand_op { + my ($self, $node, $args) = @_; + my ($op, @opargs) = @$args; + +{ $node => [ $op, map $self->expand_expr($_), @opargs ] }; +} + sub _expand_bool { my ($self, undef, $v) = @_; if (ref($v)) {