1
Fork 0

support simple interval literal interval '3 days' and rename CastOp to TypedLit

This commit is contained in:
Jake Wheat 2013-12-17 12:51:14 +02:00
parent 939189a04f
commit 045f2be825
7 changed files with 18 additions and 12 deletions
tools/Language/SQL/SimpleSQL

View file

@ -104,11 +104,11 @@ queries section
> ,"SELECT x, sum(y) FROM test1 GROUP BY x HAVING sum(y) > 3;"
> ,"SELECT x, sum(y) FROM test1 GROUP BY x HAVING x < 'c';"
> {-,"SELECT product_id, p.name, (sum(s.units) * (p.price - p.cost)) AS profit\n\
> ,"SELECT product_id, p.name, (sum(s.units) * (p.price - p.cost)) AS profit\n\
> \ FROM products p LEFT JOIN sales s USING (product_id)\n\
> \ WHERE s.date > CURRENT_DATE - INTERVAL '4 weeks'\n\
> \ GROUP BY product_id, p.name, p.price, p.cost\n\
> \ HAVING sum(p.price * s.units) > 5000;"-} -- interval syntax?
> \ HAVING sum(p.price * s.units) > 5000;"
> ,"SELECT a, b, c FROM t"
@ -219,10 +219,10 @@ select page reference
> \ FROM distributors d, films f\n\
> \ WHERE f.did = d.did"
> {-,"SELECT kind, sum(len) AS total\n\
> ,"SELECT kind, sum(len) AS total\n\
> \ FROM films\n\
> \ GROUP BY kind\n\
> \ HAVING sum(len) < interval '5 hours';"-} -- interval syntax?
> \ HAVING sum(len) < interval '5 hours';"
> ,"SELECT * FROM distributors ORDER BY name;"
> ,"SELECT * FROM distributors ORDER BY 2;"

View file

@ -36,6 +36,7 @@ Tests for parsing scalar expressions
> ,("'1'", StringLit "1")
> ,("interval '3' day", IntervalLit "3" "day" Nothing)
> ,("interval '3' day (3)", IntervalLit "3" "day" $ Just 3)
> ,("interval '3 weeks'", TypedLit (TypeName "interval") "3 weeks")
> ]
> identifiers :: TestItem
@ -116,13 +117,13 @@ Tests for parsing scalar expressions
> ,Cast (StringLit "1") $ TypeName "int")
> ,("int '3'"
> ,CastOp (TypeName "int") "3")
> ,TypedLit (TypeName "int") "3")
> ,("cast('1' as double precision)"
> ,Cast (StringLit "1") $ TypeName "double precision")
> ,("double precision '3'"
> ,CastOp (TypeName "double precision") "3")
> ,TypedLit (TypeName "double precision") "3")
> ]
> subqueries :: TestItem