start work on cast expressions, add lots more test targets
This commit is contained in:
parent
a81f62b940
commit
aa26603a0c
5 changed files with 857 additions and 36 deletions
Language/SQL/SimpleSQL
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue