[Bast-commits] r9698 - SQL-Abstract/1.x/trunk/lib/SQL/Abstract
frew at dev.catalyst.perl.org
frew at dev.catalyst.perl.org
Wed Sep 8 03:04:11 GMT 2010
Author: frew
Date: 2010-09-08 04:04:11 +0100 (Wed, 08 Sep 2010)
New Revision: 9698
Modified:
SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm
Log:
slightly nicer newline handling for stuff in parens
Modified: SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm
===================================================================
--- SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm 2010-09-08 02:57:08 UTC (rev 9697)
+++ SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm 2010-09-08 03:04:11 UTC (rev 9698)
@@ -4,6 +4,7 @@
use warnings;
use Carp;
+use List::Util;
use base 'Class::Accessor::Grouped';
@@ -290,11 +291,11 @@
sub indent { ($_[0]->indent_string||'') x ( ( $_[0]->indent_amount || 0 ) * $_[1] ) }
-sub _is_select {
- my $tree = shift;
+sub _is_key {
+ my ($self, $tree) = @_;
$tree = $tree->[0] while ref $tree;
- defined $tree && lc $tree eq 'select';
+ defined $tree && defined $self->indentmap->{lc $tree};
}
sub unparse {
@@ -319,7 +320,7 @@
return '(' .
join(' ',
map $self->unparse($_, $depth + 2), @{$cdr}) .
- (_is_select($cdr)?( $self->newline||'' ).$self->indent($depth + 1):'') . ') ';
+ ($self->_is_key($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