From: Matt S Trout Date: Mon, 9 Sep 2019 00:21:47 +0000 (+0000) Subject: better indentation and interpolation X-Git-Tag: v2.000000~3^2~152 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cdbf093ff9faeeb9e610f98a42efd9ab2df234cc;p=dbsrgits%2FSQL-Abstract.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/;