From: Matt S Trout Date: Sat, 14 Sep 2019 02:28:51 +0000 (+0000) Subject: more formatting cleanup X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ac7992be3a110ecee594f667f67755e2182fbf94;p=scpubgit%2FQ-Branch.git more formatting cleanup --- diff --git a/lib/SQL/Abstract/ExtraClauses.pm b/lib/SQL/Abstract/ExtraClauses.pm index b18d724..c9b332a 100644 --- a/lib/SQL/Abstract/ExtraClauses.pm +++ b/lib/SQL/Abstract/ExtraClauses.pm @@ -281,8 +281,9 @@ sub _render_as { my ($self, undef, $args) = @_; my ($thing, $alias) = @$args; return $self->join_query_parts( - ' '.$self->format_keyword('as').' ', + ' ', $thing, + $self->format_keyword('as'), $alias, ); } diff --git a/lib/SQL/Abstract/Formatter.pm b/lib/SQL/Abstract/Formatter.pm index f337a25..28936b2 100644 --- a/lib/SQL/Abstract/Formatter.pm +++ b/lib/SQL/Abstract/Formatter.pm @@ -49,11 +49,13 @@ sub _fold_sql { my $already = !($line eq $indent0 or $line eq $line_orig); push @res, $line.($already ? $join : '').'('."\n"; my (undef, undef, $inner) = @$p; - my $fold_indent = $already ? $indent : $next_indent; - my $folded = $self->_fold_sql($fold_indent, $fold_indent, @$inner); + my $folded = $self->_fold_sql($next_indent, $next_indent, @$inner); + $folded =~ s/\n\Z//; push @res, $folded."\n"; $line_orig = $line - = $indent0.')'.($nl_post and $idx < $#parts ? ' '.$nl_post : ''); + = $indent0.')'.( + ($nl_post and $idx < $#parts) ? ' '.$nl_post : ' ' + ); next PART; } push @res, $line.$nl_pre."\n" if $line ne $line_orig; @@ -61,7 +63,8 @@ sub _fold_sql { $line_proto = $line; next PART; } - my $folded = $self->_fold_sql($line_proto, $next_indent, @$p); + my $innerdent = @res ? $indent : $next_indent; + my $folded = $self->_fold_sql($line_proto, $innerdent, @$p); $folded =~ s/\n\Z//; push @res, $folded.$nl_pre."\n"; $line_orig = $line = $idx == $#parts ? '' : $line_proto;