[Bast-commits] r9671 -
SQL-Abstract/1.x/branches/sqla-tree/lib/SQL/Abstract
frew at dev.catalyst.perl.org
frew at dev.catalyst.perl.org
Thu Sep 2 04:14:44 GMT 2010
Author: frew
Date: 2010-09-02 05:14:44 +0100 (Thu, 02 Sep 2010)
New Revision: 9671
Modified:
SQL-Abstract/1.x/branches/sqla-tree/lib/SQL/Abstract/Tree.pm
Log:
good formatting for both subqueries and otherwise
Modified: SQL-Abstract/1.x/branches/sqla-tree/lib/SQL/Abstract/Tree.pm
===================================================================
--- SQL-Abstract/1.x/branches/sqla-tree/lib/SQL/Abstract/Tree.pm 2010-09-02 04:03:05 UTC (rev 9670)
+++ SQL-Abstract/1.x/branches/sqla-tree/lib/SQL/Abstract/Tree.pm 2010-09-02 04:14:44 UTC (rev 9671)
@@ -205,6 +205,13 @@
sub indent { ' ' x $_[1] }
+sub _is_select {
+ my $tree = shift;
+ $tree = $tree->[0] while ref $tree;
+
+ lc $tree eq 'select';
+}
+
sub unparse {
my ($self, $tree, $depth) = @_;
@@ -226,8 +233,8 @@
elsif ($car eq 'PAREN') {
return '(' .
join(' ',
- map $self->unparse($_, $depth + 1), @{$cdr})
- . ')';
+ map $self->unparse($_, $depth + 2), @{$cdr}) .
+ (_is_select($cdr)?$self->newline.$self->indent($depth + 1):'') . ')';
}
elsif ($car eq 'OR' or $car eq 'AND' or (grep { $car =~ /^ $_ $/xi } @binary_op_keywords ) ) {
return join (" $car ", map $self->unparse($_, $depth), @{$cdr});
More information about the Bast-commits
mailing list