From: Matt S Trout Date: Sun, 7 Apr 2019 23:45:01 +0000 (+0000) Subject: clean up expansion X-Git-Tag: v2.000000~3^2~266 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=958944296097534083f308ce201fcf05424c92fd;p=dbsrgits%2FSQL-Abstract.git clean up expansion --- diff --git a/lib/SQL/Abstract/Clauses.pm b/lib/SQL/Abstract/Clauses.pm index 9f92b00..3e062fb 100644 --- a/lib/SQL/Abstract/Clauses.pm +++ b/lib/SQL/Abstract/Clauses.pm @@ -61,14 +61,18 @@ sub _expand_statement { my ($self, $type, $args) = @_; my $ec = $self->{expand_clause}; return +{ "-${type}" => +{ - map +($_ => (do { + map { my $val = $args->{$_}; if (defined($val) and my $exp = $ec->{"${type}.$_"}) { - $self->$exp($val); + if ((my (@exp) = $self->$exp($val)) == 1) { + ($_ => $exp[0]) + } else { + @exp + } } else { - $val; + ($_ => $val) } - })), sort keys %$args + } sort keys %$args } }; }