[Bast-commits] r9772 - in SQL-Abstract/1.x/trunk: lib/SQL/Abstract t

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Thu Oct 21 13:53:11 GMT 2010


Author: ribasushi
Date: 2010-10-21 13:53:11 +0000 (Thu, 21 Oct 2010)
New Revision: 9772

Modified:
   SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm
   SQL-Abstract/1.x/trunk/t/13whitespace_keyword.t
   SQL-Abstract/1.x/trunk/t/15placeholders.t
Log:
Fix incorrect padding

Modified: SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm
===================================================================
--- SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm	2010-10-21 13:36:51 UTC (rev 9771)
+++ SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm	2010-10-21 13:53:11 UTC (rev 9772)
@@ -377,7 +377,7 @@
       $before = $self->newline . $self->indent($depth + $self->indentmap->{lc $keyword});
    }
    $before = '' if $depth == 0 and defined $starters{lc $keyword};
-   return [$before, ' '];
+   return [$before, ''];
 }
 
 sub indent { ($_[0]->indent_string||'') x ( ( $_[0]->indent_amount || 0 ) * $_[1] ) }
@@ -434,10 +434,14 @@
     return $self->fill_in_placeholder($bindargs);
   }
   elsif ($car eq 'PAREN') {
-    return '(' .
-      join(' ',
-        map $self->_unparse($_, $bindargs, $depth + 2), @{$cdr}) .
-    ($self->_is_key($cdr)?( $self->newline||'' ).$self->indent($depth + 1):'') . ') ';
+    return sprintf ('(%s)',
+      join (' ', map { $self->_unparse($_, $bindargs, $depth + 2) } @{$cdr} )
+        .
+      ($self->_is_key($cdr)
+        ? ( $self->newline||'' ) . $self->indent($depth + 1)
+        : ''
+      )
+    );
   }
   elsif ($car eq 'AND' or $car eq 'OR' or $car =~ / ^ $binary_op_re $ /x ) {
     return join (" $car ", map $self->_unparse($_, $bindargs, $depth), @{$cdr});

Modified: SQL-Abstract/1.x/trunk/t/13whitespace_keyword.t
===================================================================
--- SQL-Abstract/1.x/trunk/t/13whitespace_keyword.t	2010-10-21 13:36:51 UTC (rev 9771)
+++ SQL-Abstract/1.x/trunk/t/13whitespace_keyword.t	2010-10-21 13:53:11 UTC (rev 9772)
@@ -21,7 +21,7 @@
 
 for ( keys %{$sqlat->indentmap}) {
    my ($l, $r) = @{$sqlat->pad_keyword($_, 1)};
-   is($r, ' ', "right is a space for $_");
+   is($r, '', "right is empty for $_");
    is($l, "\n " . ' ' x $sqlat->indentmap->{$_}, "left calculated correctly for $_" );
 }
 

Modified: SQL-Abstract/1.x/trunk/t/15placeholders.t
===================================================================
--- SQL-Abstract/1.x/trunk/t/15placeholders.t	2010-10-21 13:36:51 UTC (rev 9771)
+++ SQL-Abstract/1.x/trunk/t/15placeholders.t	2010-10-21 13:53:11 UTC (rev 9772)
@@ -4,15 +4,13 @@
 use Test::More;
 use SQL::Abstract::Tree;
 
-my $placeholders = ['station', 'lolz'];
-
 {
    my $sqlat = SQL::Abstract::Tree->new({
       fill_in_placeholders => 1,
       placeholder_surround => [qw(; -)],
    });
 
-   is($sqlat->fill_in_placeholder($placeholders), q(;lolz-),
+   is($sqlat->fill_in_placeholder(['lolz']), q(;lolz-),
       'placeholders are populated correctly'
    );
 }
@@ -23,7 +21,7 @@
       placeholder_surround => [qw(< >)],
    });
 
-   is($sqlat->fill_in_placeholder($placeholders), q(<station>),
+   is($sqlat->fill_in_placeholder(['station']), q(<station>),
       'placeholders are populated correctly and in order'
    );
 }
@@ -35,7 +33,7 @@
       placeholder_surround => [qw(' ')],
    });
 
-   is $sqlat->format('SELECT ? as x, ? as y FROM Foo WHERE t > ? and z IN (?, ?, ?) ', ['frew', 'ribasushi', '2008-12-12', 1, 2, 3]),
+   is $sqlat->format('SELECT ? as x, ? as y FROM Foo WHERE t > ? and z IN (?, ?, ?) ', [qw/frew ribasushi 2008-12-12 1 2 3/]),
    q[SELECT 'frew' as x, 'ribasushi' as y FROM Foo WHERE t > '2008-12-12' AND z IN ('1', '2', '3')], 'Complex placeholders work';
 }
 




More information about the Bast-commits mailing list