From: Peter Rabbitson Date: Fri, 7 Jan 2011 09:40:14 +0000 (+0100) Subject: Add some crazy malformed SQL to make sure things do not throw X-Git-Tag: v1.73_01~18 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=449e13208e09551b354d65df1fa055442be71ad0;p=dbsrgits%2FSQL-Abstract.git Add some crazy malformed SQL to make sure things do not throw It looks like the empty-not-undef fix in 7cc47319 also fixes the general issue of throwing on unknown operators (e.g. reverting af75bd59 would still yield passing code, though the AST will still be incorrect). Add a currently passing test as a reminder of what stuff to look for --- diff --git a/t/14roundtrippin.t b/t/14roundtrippin.t index 63fb7a4..7df3010 100644 --- a/t/14roundtrippin.t +++ b/t/14roundtrippin.t @@ -1,6 +1,8 @@ #!/usr/bin/env perl use Test::More; +use Test::Exception; + use SQL::Abstract::Test import => ['is_same_sql']; use SQL::Abstract::Tree; @@ -27,4 +29,19 @@ for (@sql) { my $sql = 'SELECT COUNT( * ) FROM foo'; is($sqlat->format($sql), $sql, 'Roundtripping to mysql-compatible paren. syntax'); +lives_ok { $sqlat->unparse( $sqlat->parse( <<'EOS' ) ) } 'Able to parse/unparse grossly malformed sql'; +SELECT + ( + SELECT *, * FROM EXISTS bar JOIN ON a = b + NOT WHERE c !!= d + ), + NOT x, + ( + SELECT * FROM bar WHERE NOT NOT EXISTS (SELECT 1) + ), +WHERE NOT NOT 1 AND OR foo IN (1,2,,,3,,,), +GROUP BY bar + +EOS + done_testing;