1
Fork 0

start work on cast expressions, add lots more test targets

This commit is contained in:
Jake Wheat 2013-12-13 18:50:41 +02:00
parent a81f62b940
commit aa26603a0c
5 changed files with 857 additions and 36 deletions
Language/SQL/SimpleSQL

View file

@ -47,6 +47,13 @@ back into SQL source text. It attempts to format the output nicely.
> ,text "then" <+> scalarExpr t1]
> e el = text "else" <+> scalarExpr el
> scalarExpr (Parens e) = parens $ scalarExpr e
> scalarExpr (Cast e (TypeName tn)) =
> text "cast" <> parens (sep [scalarExpr e
> ,text "as"
> ,text tn])
> scalarExpr (CastOp s (TypeName tn)) =
> text tn <+> quotes (text s)
= query expressions

View file

@ -1,13 +1,14 @@
> module Language.SQL.SimpleSQL.Syntax
> (QueryExpr(..)
> (ScalarExpr(..)
> ,TypeName(..)
> ,QueryExpr(..)
> ,makeSelect
> ,ScalarExpr(..)
> ,Duplicates(..)
> ,Direction(..)
> ,TableRef(..)
> ,JoinType(..)
> ,JoinCondition(..)
> ,Duplicates(..)
> ,Direction(..)
> ) where
@ -23,8 +24,12 @@
> [(ScalarExpr,ScalarExpr)] -- when branches
> (Maybe ScalarExpr) -- else value
> | Parens ScalarExpr
> | Cast ScalarExpr TypeName
> | CastOp String TypeName
> deriving (Eq,Show)
> data TypeName = TypeName String deriving (Eq,Show)
> data QueryExpr
> = Select
> {qeDuplicates :: Duplicates