[Bast-commits] r9769 - in SQL-Abstract/1.x/trunk: . lib/SQL/Abstract
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Thu Oct 21 12:49:12 GMT 2010
Author: ribasushi
Date: 2010-10-21 12:49:11 +0000 (Thu, 21 Oct 2010)
New Revision: 9769
Modified:
SQL-Abstract/1.x/trunk/Changes
SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm
Log:
Preserve \@bindargs passed to unparse()
Modified: SQL-Abstract/1.x/trunk/Changes
===================================================================
--- SQL-Abstract/1.x/trunk/Changes 2010-10-21 12:39:16 UTC (rev 9768)
+++ SQL-Abstract/1.x/trunk/Changes 2010-10-21 12:49:11 UTC (rev 9769)
@@ -8,6 +8,7 @@
- Add proper handling of lists (foo,bar,?)
- Better handling of generic -function's during AST construction
- Special handle IS NOT? NULL
+ - Make sure unparse() does not destroy a passed in \@bindargs
revision 1.68 2010-09-16
----------------------------
Modified: SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm
===================================================================
--- SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm 2010-10-21 12:39:16 UTC (rev 9768)
+++ SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm 2010-10-21 12:49:11 UTC (rev 9769)
@@ -395,11 +395,15 @@
return '?'
}
+# FIXME - terrible name for a user facing API
sub unparse {
+ my ($self, $tree, $bindargs) = @_;
+ $self->_unparse($tree, [@{$bindargs||[]}], 0);
+}
+
+sub _unparse {
my ($self, $tree, $bindargs, $depth) = @_;
- $depth ||= 0;
-
if (not $tree or not @$tree) {
return '';
}
@@ -414,7 +418,7 @@
}
if (ref $car) {
- return join (' ', map $self->unparse($_, $bindargs, $depth), @$tree);
+ return join (' ', map $self->_unparse($_, $bindargs, $depth), @$tree);
}
elsif ($car eq 'LITERAL') {
if ($cdr->[0] eq '?') {
@@ -425,18 +429,18 @@
elsif ($car eq 'PAREN') {
return '(' .
join(' ',
- map $self->unparse($_, $bindargs, $depth + 2), @{$cdr}) .
+ 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});
+ return join (" $car ", map $self->_unparse($_, $bindargs, $depth), @{$cdr});
}
elsif ($car eq 'LIST' ) {
- return join (', ', map $self->unparse($_, $bindargs, $depth), @{$cdr});
+ return join (', ', map $self->_unparse($_, $bindargs, $depth), @{$cdr});
}
else {
my ($l, $r) = @{$self->pad_keyword($car, $depth)};
- return sprintf "$l%s %s$r", $self->format_keyword($car), $self->unparse($cdr, $bindargs, $depth);
+ return sprintf "$l%s %s$r", $self->format_keyword($car), $self->_unparse($cdr, $bindargs, $depth);
}
}
More information about the Bast-commits
mailing list