From: Matt S Trout Date: Sat, 16 Feb 2019 03:06:34 +0000 (+0000) Subject: don't parenthesise single clause and/or because, well, don't be silly X-Git-Tag: v1.90_01~402 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=230812fc3056554ce75ee8d240d2345bc14f0fde;p=dbsrgits%2FSQL-Abstract.git don't parenthesise single clause and/or because, well, don't be silly --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 5b93238..621a9a7 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -1002,7 +1002,9 @@ sub _render_op { return (($op eq 'not' || $us ? '('.$final_sql.')' : $final_sql), @bind); } else { my @parts = map [ $self->_render_expr($_) ], @args; - my ($final_sql) = map +($op =~ /^(and|or)$/ ? "( ${_} )" : $_), join( + my $is_andor = !!($op =~ /^(and|or)$/); + return @{$parts[0]} if $is_andor and @parts == 1; + my ($final_sql) = map +($is_andor ? "( ${_} )" : $_), join( ($final_op eq ',' ? '' : ' ').$self->_sqlcase($final_op).' ', map $_->[0], @parts );