diff options
Diffstat (limited to 'tests/fixtures/optimizer/optimizer.sql')
-rw-r--r-- | tests/fixtures/optimizer/optimizer.sql | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/tests/fixtures/optimizer/optimizer.sql b/tests/fixtures/optimizer/optimizer.sql index 38e64d7..4b58ea5 100644 --- a/tests/fixtures/optimizer/optimizer.sql +++ b/tests/fixtures/optimizer/optimizer.sql @@ -701,3 +701,108 @@ SELECT "x"."a" * "x"."b" - "x"."b" ) AS "f" FROM "x" AS "x"; + +# title: wrapped table without alias +# execute: false +SELECT * FROM (tbl); +SELECT + * +FROM ( + "tbl" AS "tbl" +); + +# title: wrapped table with alias +# execute: false +SELECT * FROM (tbl AS tbl); +SELECT + * +FROM ( + "tbl" AS "tbl" +); + +# title: wrapped join of tables without alias +SELECT a, c FROM (x LEFT JOIN y ON a = c); +SELECT + "x"."a" AS "a", + "y"."c" AS "c" +FROM ( + "x" AS "x" + LEFT JOIN "y" AS "y" + ON "x"."a" = "y"."c" +); + +# title: wrapped join of tables with alias +# execute: false +SELECT a, c FROM (x LEFT JOIN y ON a = c) AS t; +SELECT + "x"."a" AS "a", + "y"."c" AS "c" +FROM "x" AS "x" +LEFT JOIN "y" AS "y" + ON "x"."a" = "y"."c"; + +# title: chained wrapped joins without aliases +# execute: false +SELECT * FROM ((a CROSS JOIN ((b CROSS JOIN c) CROSS JOIN (d CROSS JOIN e)))); +SELECT + * +FROM ( + ( + "a" AS "a" + CROSS JOIN ( + ( + "b" AS "b" + CROSS JOIN "c" AS "c" + ) + CROSS JOIN ( + "d" AS "d" + CROSS JOIN "e" AS "e" + ) + ) + ) +); + +# title: chained wrapped joins with aliases +# execute: false +SELECT * FROM ((a AS foo CROSS JOIN b AS bar) CROSS JOIN c AS baz); +SELECT + * +FROM ( + ( + "a" AS "foo" + CROSS JOIN "b" AS "bar" + ) + CROSS JOIN "c" AS "baz" +); + +# title: table joined with join construct +SELECT x.a, y.b, z.c FROM x LEFT JOIN (y INNER JOIN z ON y.c = z.c) ON x.b = y.b; +SELECT + "x"."a" AS "a", + "y"."b" AS "b", + "z"."c" AS "c" +FROM "x" AS "x" +LEFT JOIN ( + "y" AS "y" + JOIN "z" AS "z" + ON "y"."c" = "z"."c" +) + ON "x"."b" = "y"."b"; + +# title: select * from table joined with join construct +# execute: false +SELECT * FROM x LEFT JOIN (y INNER JOIN z ON y.c = z.c) ON x.b = y.b; +SELECT + "y"."b" AS "b", + "y"."c" AS "c", + "z"."a" AS "a", + "z"."c" AS "c", + "x"."a" AS "a", + "x"."b" AS "b" +FROM "x" AS "x" +LEFT JOIN ( + "y" AS "y" + JOIN "z" AS "z" + ON "y"."c" = "z"."c" +) + ON "x"."b" = "y"."b"; |