rearrange the test code and add some notes on postgres
This commit is contained in:
parent
86ba354e26
commit
6ff8c9ddc5
10 changed files with 940 additions and 591 deletions
tools/Language/SQL/SimpleSQL
73
tools/Language/SQL/SimpleSQL/TableRefs.lhs
Normal file
73
tools/Language/SQL/SimpleSQL/TableRefs.lhs
Normal file
|
@ -0,0 +1,73 @@
|
|||
|
||||
These are the tests for parsing focusing on the from part of query
|
||||
expression
|
||||
|
||||
> module Language.SQL.SimpleSQL.TableRefs (tableRefTests) where
|
||||
|
||||
> import Language.SQL.SimpleSQL.TestTypes
|
||||
> import Language.SQL.SimpleSQL.Syntax
|
||||
|
||||
|
||||
> tableRefTests :: TestItem
|
||||
> tableRefTests = Group "tableRefTests" $ map (uncurry TestQueryExpr)
|
||||
> [("select a from t"
|
||||
> ,ms [TRSimple "t"])
|
||||
|
||||
> ,("select a from t,u"
|
||||
> ,ms [TRSimple "t", TRSimple "u"])
|
||||
|
||||
> ,("select a from t inner join u on expr"
|
||||
> ,ms [TRJoin (TRSimple "t") JInner (TRSimple "u")
|
||||
> (Just $ JoinOn $ Iden "expr")])
|
||||
|
||||
> ,("select a from t left join u on expr"
|
||||
> ,ms [TRJoin (TRSimple "t") JLeft (TRSimple "u")
|
||||
> (Just $ JoinOn $ Iden "expr")])
|
||||
|
||||
> ,("select a from t right join u on expr"
|
||||
> ,ms [TRJoin (TRSimple "t") JRight (TRSimple "u")
|
||||
> (Just $ JoinOn $ Iden "expr")])
|
||||
|
||||
> ,("select a from t full join u on expr"
|
||||
> ,ms [TRJoin (TRSimple "t") JFull (TRSimple "u")
|
||||
> (Just $ JoinOn $ Iden "expr")])
|
||||
|
||||
> ,("select a from t cross join u"
|
||||
> ,ms [TRJoin (TRSimple "t")
|
||||
> JCross (TRSimple "u") Nothing])
|
||||
|
||||
> ,("select a from t natural inner join u"
|
||||
> ,ms [TRJoin (TRSimple "t") JInner (TRSimple "u")
|
||||
> (Just JoinNatural)])
|
||||
|
||||
> ,("select a from t inner join u using(a,b)"
|
||||
> ,ms [TRJoin (TRSimple "t") JInner (TRSimple "u")
|
||||
> (Just $ JoinUsing ["a", "b"])])
|
||||
|
||||
> ,("select a from (select a from t)"
|
||||
> ,ms [TRQueryExpr $ ms [TRSimple "t"]])
|
||||
|
||||
> ,("select a from t as u"
|
||||
> ,ms [TRAlias (TRSimple "t") "u" Nothing])
|
||||
|
||||
> ,("select a from t u"
|
||||
> ,ms [TRAlias (TRSimple "t") "u" Nothing])
|
||||
|
||||
> ,("select a from t u(b)"
|
||||
> ,ms [TRAlias (TRSimple "t") "u" $ Just ["b"]])
|
||||
|
||||
> ,("select a from (t cross join u) as u"
|
||||
> ,ms [TRAlias (TRParens $
|
||||
> TRJoin (TRSimple "t") JCross (TRSimple "u") Nothing)
|
||||
> "u" Nothing])
|
||||
> -- todo: not sure if the associativity is correct
|
||||
|
||||
> ,("select a from t cross join u cross join v",
|
||||
> ms [TRJoin
|
||||
> (TRJoin (TRSimple "t")
|
||||
> JCross (TRSimple "u") Nothing)
|
||||
> JCross (TRSimple "v") Nothing])
|
||||
> ]
|
||||
> where
|
||||
> ms f = makeSelect {qeSelectList = [(Nothing,Iden "a")]
|
||||
> ,qeFrom = f}
|
Loading…
Add table
Add a link
Reference in a new issue