diff --git a/tools/Language/SQL/SimpleSQL/GroupBy.lhs b/tools/Language/SQL/SimpleSQL/GroupBy.lhs index 82eddb2..2fd43a4 100644 --- a/tools/Language/SQL/SimpleSQL/GroupBy.lhs +++ b/tools/Language/SQL/SimpleSQL/GroupBy.lhs @@ -218,7 +218,8 @@ sure which sql version they were introduced, 1999 or 2003 I think). > \GROUP BY GROUPING SETS ((R1, ROLLUP(WEEK(SALES_DATE),\n\ > \DAYOFWEEK(SALES_DATE))),\n\ > \(R2,ROLLUP( MONTH(SALES_DATE), REGION ) ))\n\ -> \ORDER BY GROUP, WEEK, DAY_WEEK, MONTH, REGION"-} -- as group - needs more subtle keyword blacklisting +> \ORDER BY GROUP, WEEK, DAY_WEEK, MONTH, REGION"-} +> -- as group - needs more subtle keyword blacklisting > ,"SELECT MONTH(SALES_DATE) AS MONTH,\n\ > \REGION,\n\ diff --git a/tools/Language/SQL/SimpleSQL/Postgres.lhs b/tools/Language/SQL/SimpleSQL/Postgres.lhs index 506013c..81a52d5 100644 --- a/tools/Language/SQL/SimpleSQL/Postgres.lhs +++ b/tools/Language/SQL/SimpleSQL/Postgres.lhs @@ -18,7 +18,8 @@ TODO: get all the commented out tests working > [-- "SELECT 'foo'\n\ > -- \'bar';" -- this should parse as select 'foobar' > -- , -> "SELECT name, (SELECT max(pop) FROM cities WHERE cities.state = states.name)\n\ +> "SELECT name, (SELECT max(pop) FROM cities\n\ +> \ WHERE cities.state = states.name)\n\ > \ FROM states;" > ,"SELECT ROW(1,2.5,'this is a test');" @@ -47,8 +48,10 @@ queries section > ,"SELECT * FROM t1 LEFT JOIN t2 ON t1.num = t2.num AND t2.value = 'xxx';" > ,"SELECT * FROM t1 LEFT JOIN t2 ON t1.num = t2.num WHERE t2.value = 'xxx';" -> ,"SELECT * FROM some_very_long_table_name s JOIN another_fairly_long_name a ON s.id = a.num;" -> ,"SELECT * FROM people AS mother JOIN people AS child ON mother.id = child.mother_id;" +> ,"SELECT * FROM some_very_long_table_name s\n\ +> \JOIN another_fairly_long_name a ON s.id = a.num;" +> ,"SELECT * FROM people AS mother JOIN people AS child\n\ +> \ ON mother.id = child.mother_id;" > ,"SELECT * FROM my_table AS a CROSS JOIN my_table AS b;" > ,"SELECT * FROM (my_table AS a CROSS JOIN my_table) AS b;" > ,"SELECT * FROM getfoo(1) AS t1;" @@ -63,7 +66,7 @@ queries section > \ AS t1(proname name, prosrc text)\n\ > \ WHERE proname LIKE 'bytea%';"-} -- types in the alias?? -> ,"SELECT * FROM foo, LATERAL (SELECT * FROM bar WHERE bar.id = foo.bar_id) ss;" -- lateral +> ,"SELECT * FROM foo, LATERAL (SELECT * FROM bar WHERE bar.id = foo.bar_id) ss;" > ,"SELECT * FROM foo, bar WHERE bar.id = foo.bar_id;" > {-,"SELECT p1.id, p2.id, v1, v2\n\ @@ -90,7 +93,8 @@ queries section > ,"SELECT * FROM fdt WHERE c1 IN (SELECT c3 FROM t2 WHERE c2 = fdt.c1 + 10)" -> ,"SELECT * FROM fdt WHERE c1 BETWEEN (SELECT c3 FROM t2 WHERE c2 = fdt.c1 + 10) AND 100" +> ,"SELECT * FROM fdt WHERE c1 BETWEEN \n\ +> \ (SELECT c3 FROM t2 WHERE c2 = fdt.c1 + 10) AND 100" > ,"SELECT * FROM fdt WHERE EXISTS (SELECT c1 FROM t2 WHERE c2 > fdt.c1)" diff --git a/tools/Language/SQL/SimpleSQL/ScalarExprs.lhs b/tools/Language/SQL/SimpleSQL/ScalarExprs.lhs index 611ff2b..7beecab 100644 --- a/tools/Language/SQL/SimpleSQL/ScalarExprs.lhs +++ b/tools/Language/SQL/SimpleSQL/ScalarExprs.lhs @@ -83,7 +83,8 @@ Tests for parsing scalar expressions > ,("case a when 1 then 2 when 3 then 4 else 5 end" > ,Case (Just $ Iden "a") [([NumLit "1"], NumLit "2") -> ,([NumLit "3"], NumLit "4")] (Just $ NumLit "5")) +> ,([NumLit "3"], NumLit "4")] +> (Just $ NumLit "5")) > ,("case when a=1 then 2 when a=3 then 4 else 5 end" > ,Case Nothing [([BinOp (Iden "a") "=" (NumLit "1")], NumLit "2") @@ -249,38 +250,50 @@ Tests for parsing scalar expressions > ,WindowApp "max" [Iden "a"] [Iden "b",Iden "c"] [] Nothing) > ,("sum(a) over (order by b)" -> ,WindowApp "sum" [Iden "a"] [] [OrderField (Iden "b") Asc NullsOrderDefault] Nothing) +> ,WindowApp "sum" [Iden "a"] [] +> [OrderField (Iden "b") Asc NullsOrderDefault] Nothing) > ,("sum(a) over (order by b desc,c)" -> ,WindowApp "sum" [Iden "a"] [] [OrderField (Iden "b") Desc NullsOrderDefault -> ,OrderField (Iden "c") Asc NullsOrderDefault] Nothing) +> ,WindowApp "sum" [Iden "a"] [] +> [OrderField (Iden "b") Desc NullsOrderDefault +> ,OrderField (Iden "c") Asc NullsOrderDefault] Nothing) > ,("sum(a) over (partition by b order by c)" -> ,WindowApp "sum" [Iden "a"] [Iden "b"] [OrderField (Iden "c") Asc NullsOrderDefault] Nothing) +> ,WindowApp "sum" [Iden "a"] [Iden "b"] +> [OrderField (Iden "c") Asc NullsOrderDefault] Nothing) > ,("sum(a) over (partition by b order by c range unbounded preceding)" -> ,WindowApp "sum" [Iden "a"] [Iden "b"] [OrderField (Iden "c") Asc NullsOrderDefault] +> ,WindowApp "sum" [Iden "a"] [Iden "b"] +> [OrderField (Iden "c") Asc NullsOrderDefault] > $ Just $ FrameFrom FrameRange UnboundedPreceding) > ,("sum(a) over (partition by b order by c range 5 preceding)" -> ,WindowApp "sum" [Iden "a"] [Iden "b"] [OrderField (Iden "c") Asc NullsOrderDefault] +> ,WindowApp "sum" [Iden "a"] [Iden "b"] +> [OrderField (Iden "c") Asc NullsOrderDefault] > $ Just $ FrameFrom FrameRange $ Preceding (NumLit "5")) > ,("sum(a) over (partition by b order by c range current row)" -> ,WindowApp "sum" [Iden "a"] [Iden "b"] [OrderField (Iden "c") Asc NullsOrderDefault] +> ,WindowApp "sum" [Iden "a"] [Iden "b"] +> [OrderField (Iden "c") Asc NullsOrderDefault] > $ Just $ FrameFrom FrameRange Current) > ,("sum(a) over (partition by b order by c rows 5 following)" -> ,WindowApp "sum" [Iden "a"] [Iden "b"] [OrderField (Iden "c") Asc NullsOrderDefault] +> ,WindowApp "sum" [Iden "a"] [Iden "b"] +> [OrderField (Iden "c") Asc NullsOrderDefault] > $ Just $ FrameFrom FrameRows $ Following (NumLit "5")) > ,("sum(a) over (partition by b order by c range unbounded following)" -> ,WindowApp "sum" [Iden "a"] [Iden "b"] [OrderField (Iden "c") Asc NullsOrderDefault] +> ,WindowApp "sum" [Iden "a"] [Iden "b"] +> [OrderField (Iden "c") Asc NullsOrderDefault] > $ Just $ FrameFrom FrameRange UnboundedFollowing) -> ,("sum(a) over (partition by b order by c range between 5 preceding and 5 following)" -> ,WindowApp "sum" [Iden "a"] [Iden "b"] [OrderField (Iden "c") Asc NullsOrderDefault] -> $ Just $ FrameBetween FrameRange (Preceding (NumLit "5")) (Following (NumLit "5"))) +> ,("sum(a) over (partition by b order by c \n\ +> \range between 5 preceding and 5 following)" +> ,WindowApp "sum" [Iden "a"] [Iden "b"] +> [OrderField (Iden "c") Asc NullsOrderDefault] +> $ Just $ FrameBetween FrameRange +> (Preceding (NumLit "5")) +> (Following (NumLit "5"))) > ]