From: Matt S Trout Date: Thu, 11 Apr 2019 01:30:51 +0000 (+0000) Subject: expand function arguments X-Git-Tag: v2.000000~3^2~253 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a34bb8da3cf262d741895474e98fbdb1ecdbb3b1;p=dbsrgits%2FSQL-Abstract.git expand function arguments --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index c7e0759..78407a5 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -208,6 +208,7 @@ sub new { (map +($_ => '_expand_op_is'), ('is', 'is_not')), ident => '_expand_ident', value => '_expand_value', + func => '_expand_func', }; $opt{expand_op} = { @@ -734,7 +735,11 @@ sub _expand_hashpair_op { return +{ -op => [ $func, $self->_expand_expr($v) ] }; } } - return +{ -func => [ $func, $self->_expand_expr($v) ] }; + return +{ -func => [ + $func, + map $self->_expand_expr($_), + ref($v) eq 'ARRAY' ? @$v : $v + ] }; } # scalars and literals get simply expanded @@ -847,6 +852,12 @@ sub _dwim_op_to_is { puke(sprintf $fail, $op); } +sub _expand_func { + my ($self, undef, $args) = @_; + my ($func, @args) = @$args; + return { -func => [ $func, map $self->expand_expr($_), @args ] }; +} + sub _expand_ident { my ($self, undef, $body, $k) = @_; return $self->_expand_hashpair_cmp(