2013-12-17 10:40:31 +01:00
|
|
|
|
|
|
|
Some tests for parsing full queries.
|
|
|
|
|
2013-12-17 12:21:36 +01:00
|
|
|
> {-# LANGUAGE OverloadedStrings #-}
|
2013-12-17 10:40:31 +01:00
|
|
|
> module Language.SQL.SimpleSQL.FullQueries (fullQueriesTests) where
|
|
|
|
|
|
|
|
> import Language.SQL.SimpleSQL.TestTypes
|
|
|
|
> import Language.SQL.SimpleSQL.Syntax
|
|
|
|
|
|
|
|
|
|
|
|
> fullQueriesTests :: TestItem
|
|
|
|
> fullQueriesTests = Group "queries" $ map (uncurry TestQueryExpr)
|
|
|
|
> [("select count(*) from t"
|
|
|
|
> ,makeSelect
|
2013-12-31 10:31:00 +01:00
|
|
|
> {qeSelectList = [(App "count" [Star], Nothing)]
|
2013-12-17 10:40:31 +01:00
|
|
|
> ,qeFrom = [TRSimple "t"]
|
|
|
|
> }
|
|
|
|
> )
|
|
|
|
|
|
|
|
> ,("select a, sum(c+d) as s\n\
|
|
|
|
> \ from t,u\n\
|
|
|
|
> \ where a > 5\n\
|
|
|
|
> \ group by a\n\
|
|
|
|
> \ having count(1) > 5\n\
|
|
|
|
> \ order by s"
|
|
|
|
> ,makeSelect
|
2013-12-31 10:31:00 +01:00
|
|
|
> {qeSelectList = [(Iden "a", Nothing)
|
|
|
|
> ,(App "sum" [BinOp (Iden "c")
|
|
|
|
> "+" (Iden "d")]
|
|
|
|
> ,Just "s")]
|
2013-12-17 10:40:31 +01:00
|
|
|
> ,qeFrom = [TRSimple "t", TRSimple "u"]
|
|
|
|
> ,qeWhere = Just $ BinOp (Iden "a") ">" (NumLit "5")
|
2013-12-17 18:17:03 +01:00
|
|
|
> ,qeGroupBy = [SimpleGroup $ Iden "a"]
|
2013-12-17 10:40:31 +01:00
|
|
|
> ,qeHaving = Just $ BinOp (App "count" [NumLit "1"])
|
|
|
|
> ">" (NumLit "5")
|
2014-04-18 10:18:21 +02:00
|
|
|
> ,qeOrderBy = [SortSpec (Iden "s") DirDefault NullsOrderDefault]
|
2013-12-17 10:40:31 +01:00
|
|
|
> }
|
|
|
|
> )
|
|
|
|
> ]
|