From: Matt S Trout Date: Tue, 2 Apr 2019 19:53:54 +0000 (+0000) Subject: cleanup multop rendering X-Git-Tag: v2.000000~3^2~285 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8795c188995f2b1759df2f704c34745a454d5c69;p=dbsrgits%2FSQL-Abstract.git cleanup multop rendering --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 09f963d..602a01d 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -1202,7 +1202,7 @@ sub _render_op_andor { my @parts = grep length($_->[0]), map [ $self->render_aqt($_) ], @$args; return '' unless @parts; return @{$parts[0]} if @parts == 1; - my ($sql, @bind) = $self->_render_op_multop($op, $args); + my ($sql, @bind) = $self->_join_parts(' '.$self->_sqlcase($op).' ', @parts); return '( '.$sql.' )', @bind; } @@ -1211,15 +1211,21 @@ sub _render_op_multop { my @parts = grep length($_->[0]), map [ $self->render_aqt($_) ], @$args; return '' unless @parts; return @{$parts[0]} if @parts == 1; - my ($final_sql) = join( - ($op eq ',' ? '' : ' ').$self->_sqlcase(join ' ', split '_', $op).' ', - map $_->[0], @parts - ); + my $join = ($op eq ',' + ? ', ' + : ' '.$self->_sqlcase(join ' ', split '_', $op).' ' + ); + return $self->_join_parts($join, @parts); +} + +sub _join_parts { + my ($self, $join, @parts) = @_; return ( - $final_sql, + join($join, map $_->[0], @parts), map @{$_}[1..$#$_], @parts ); } + sub _render_unop_paren { my ($self, $op, $v) = @_; my ($sql, @bind) = $self->_render_unop_prefix($op, $v);