From: Matt S Trout Date: Thu, 11 Apr 2019 01:30:51 +0000 (+0000) Subject: expand function arguments X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a5536efa75037f42db7dfca97ad2ed853a1c0117;p=scpubgit%2FQ-Branch.git expand function arguments --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 1435883..c8e2bac 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(