X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F11parser.t;h=202e5fa4d9916d86f9f38b5b115dd5f370d9d046;hb=1ec9b9e3261f37de1bd05b31fa3c88ab78ab1480;hp=b70cb0d57f8c6445fd4681d9e4f33a1cd8afe9d6;hpb=87abf9bc3395870cef72a3f00b7d4cfe18abd980;p=dbsrgits%2FSQL-Abstract.git diff --git a/t/11parser.t b/t/11parser.t index b70cb0d..202e5fa 100644 --- a/t/11parser.t +++ b/t/11parser.t @@ -619,18 +619,206 @@ is_deeply($sqlat->parse("SELECT x, y FROM foo WHERE x IN (?, ?, ?, ?)"), [ ] ], 'Lists parsed correctly'); +is_deeply($sqlat->parse('SELECT foo FROM bar ORDER BY x + ? DESC, oomph, y - ? DESC, unf, baz.g / ? ASC, buzz * 0 DESC, foo DESC, ickk ASC'), [ + [ + "SELECT", + [ + [ + "-LITERAL", + [ + "foo" + ] + ] + ] + ], + [ + "FROM", + [ + [ + "-LITERAL", + [ + "bar" + ] + ] + ] + ], + [ + "ORDER BY", + [ + [ + "-LIST", + [ + [ + "-DESC", + [ + [ + "-MISC", + [ + [ + "-LITERAL", + [ + "x" + ] + ], + [ + "-LITERAL", + [ + "+" + ] + ] + ] + ], + [ + "-PLACEHOLDER", + [ + "?" + ] + ] + ] + ], + [ + "-LITERAL", + [ + "oomph" + ] + ], + [ + "-DESC", + [ + [ + "-MISC", + [ + [ + "-LITERAL", + [ + "y" + ] + ], + [ + "-LITERAL", + [ + "-" + ] + ] + ] + ], + [ + "-PLACEHOLDER", + [ + "?" + ] + ] + ] + ], + [ + "-LITERAL", + [ + "unf" + ] + ], + [ + "-ASC", + [ + [ + "-MISC", + [ + [ + "-LITERAL", + [ + "baz.g" + ] + ], + [ + "-LITERAL", + [ + "/" + ] + ] + ] + ], + [ + "-PLACEHOLDER", + [ + "?" + ] + ] + ] + ], + [ + "-DESC", + [ + [ + "-MISC", + [ + [ + "-LITERAL", + [ + "buzz" + ] + ], + [ + "-LITERAL", + [ + "*" + ] + ], + [ + "-LITERAL", + [ + 0 + ] + ] + ] + ] + ] + ], + [ + "-DESC", + [ + [ + "-LITERAL", + [ + "foo" + ] + ] + ] + ], + [ + "-ASC", + [ + [ + "-LITERAL", + [ + "ickk" + ] + ] + ] + ] + ] + ] + ] + ] +], 'Crazy ORDER BY parsed correctly'); + + is_deeply($sqlat->parse("SELECT * * FROM (SELECT *, FROM foobar baz buzz) foo bar WHERE NOT NOT NOT EXISTS (SELECT 'cr,ap') AND foo.a = ? and not (foo.b LIKE 'station') and x = y and a = b and GROUP BY , ORDER BY x x1 x2 y asc, max(y) desc x z desc"), [ [ "SELECT", [ [ - "*", + "-MISC", [ [ "-LITERAL", [ "*" ] + ], + [ + "-LITERAL", + [ + "*" + ] ] ] ] @@ -855,78 +1043,76 @@ is_deeply($sqlat->parse("SELECT * * FROM (SELECT *, FROM foobar baz buzz) foo ba "-LIST", [ [ - "-MISC", - [ - [ - "-LITERAL", - [ - "x" - ] - ], - [ - "-LITERAL", - [ - "x1" - ] - ], - [ - "-LITERAL", - [ - "x2" - ] - ], - [ - "-LITERAL", - [ - "y" - ] - ], - [ - "-LITERAL", - [ - "asc" - ] - ] - ] - ], - [ - "max", + "-ASC", [ [ "-MISC", [ [ - "-DESC", + "-LITERAL", [ - [ - "-PAREN", - [ - [ - "-LITERAL", - [ - "y" - ] - ] - ] - ] + "x" ] ], [ "-LITERAL", [ - "x" + "x1" ] ], [ "-LITERAL", [ - "z" + "x2" ] ], [ "-LITERAL", [ - "desc" + "y" + ] + ] + ] + ], + ], + ], + [ + "max", + [ + [ + "-DESC", + [ + [ + "-MISC", + [ + [ + "-DESC", + [ + [ + "-PAREN", + [ + [ + "-LITERAL", + [ + "y" + ] + ] + ] + ] + ] + ], + [ + "-LITERAL", + [ + "x" + ] + ], + [ + "-LITERAL", + [ + "z" + ] + ] ] ] ]