From: Matt S Trout Date: Tue, 26 Mar 2019 02:17:56 +0000 (+0000) Subject: clean up op handling code more X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3f51d831c427cc4d89d1fa0fc004c66d9457f0da;p=scpubgit%2FQ-Branch.git clean up op handling code more --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 41a26f0..64b196a 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -1077,12 +1077,21 @@ 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); + return '( '.$sql.' )', @bind; +} + +sub _render_op_multop { + my ($self, $op, $args) = @_; + my @parts = grep length($_->[0]), map [ $self->render_aqt($_) ], @$args; + return '' unless @parts; + return @{$parts[0]} if @parts == 1; my ($final_sql) = join( ' '.$self->_sqlcase($op).' ', map $_->[0], @parts ); return ( - '('.$final_sql.')', + $final_sql, map @{$_}[1..$#$_], @parts ); } @@ -1107,16 +1116,7 @@ sub _render_op { if (@args == 1) { return $self->_render_unop_prefix($op, \@args); } else { - my @parts = grep length($_->[0]), map [ $self->render_aqt($_) ], @args; - return '' unless @parts; - my ($final_sql) = join( - ' '.$self->_sqlcase($op).' ', - map $_->[0], @parts - ); - return ( - $final_sql, - map @{$_}[1..$#$_], @parts - ); + return $self->_render_op_multop($op, \@args); } die "unhandled"; }