From: Matt S Trout Date: Tue, 2 Apr 2019 19:53:54 +0000 (+0000) Subject: cleanup multop rendering X-Git-Tag: v1.90_01~264 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fd6f6be6fccf16a8c318c13159e2b632a6f218c7;p=dbsrgits%2FSQL-Abstract.git cleanup multop rendering --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 50b464b..6b6f8c0 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);