From: Matt S Trout Date: Mon, 9 Sep 2019 00:21:47 +0000 (+0000) Subject: better indentation and interpolation X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=161d810565dbf4a3be23d02d37c3a9374511eb77;p=scpubgit%2FQ-Branch.git better indentation and interpolation --- diff --git a/lib/SQL/Abstract/Formatter.pm b/lib/SQL/Abstract/Formatter.pm index 0eb799d..6fedeb5 100644 --- a/lib/SQL/Abstract/Formatter.pm +++ b/lib/SQL/Abstract/Formatter.pm @@ -45,11 +45,11 @@ sub _fold_sql { $line .= $j_part; } else { if (ref($p) and $p->[1] eq '(' and $p->[-1] eq ')') { - push @res, $line.$join.'('."\n"; + push @res, $line.($line =~ /S/ ? $join : '').'('."\n"; my (undef, undef, $inner) = @$p; my $folded = $self->_fold_sql($indent, $indent, @$inner); - push @res, $nl_post.$folded."\n"; - $line = $indent0.')'; + push @res, $folded."\n"; + $line = $indent0.')'.($nl_post and $idx < $#parts ? ' '.$nl_post : ''); next PART; } push @res, $line.$nl_pre."\n" if $line =~ /\S/;