From: Arthur Axel "fREW" Schmidt Date: Tue, 31 Aug 2010 04:13:04 +0000 (+0000) Subject: document hopes and dreams X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d49e532353631fbb995b0047f3b3cc0f6761589f;p=scpubgit%2FQ-Branch.git document hopes and dreams --- diff --git a/lib/SQL/Abstract/Tree.pm b/lib/SQL/Abstract/Tree.pm index 73a034d..e1292f7 100644 --- a/lib/SQL/Abstract/Tree.pm +++ b/lib/SQL/Abstract/Tree.pm @@ -182,7 +182,7 @@ sub unparse { return join (" $tree->[0] ", map {unparse($_)} @{$tree->[1]}); } else { - return sprintf '%s %s', $tree->[0], unparse ($tree->[1]); + return sprintf "%s %s\n", $tree->[0], unparse ($tree->[1]); } } diff --git a/t/11unparse.t b/t/11unparse.t new file mode 100644 index 0000000..0d080f6 --- /dev/null +++ b/t/11unparse.t @@ -0,0 +1,26 @@ +use strict; +use warnings; + +use SQL::Abstract::Tree; + +{ + my $sql = "SELECT a, b, c + FROM foo WHERE foo.a =1 and foo.b LIKE 'station'"; + + print "$sql\n"; + print SQL::Abstract::Tree::unparse(SQL::Abstract::Tree::parse($sql)) . "\n"; +} + +{ + my $sql = "SELECT * + FROM (SELECT * FROM foobar) WHERE foo.a =1 and foo.b LIKE 'station'"; + + print "$sql\n"; + print SQL::Abstract::Tree::unparse(SQL::Abstract::Tree::parse($sql)) . "\n"; +} + +# stuff we want: +# Nested indentation +# Max Width +# Color coding (console) +# Color coding (html)