implement extract
This commit is contained in:
parent
a001d120c1
commit
5e56a4b560
3 changed files with 14 additions and 2 deletions
Language/SQL/SimpleSQL
|
@ -172,6 +172,13 @@ to be.
|
|||
> prefixCast = try (CastOp <$> typeName
|
||||
> <*> stringLiteral)
|
||||
|
||||
> extract :: P ScalarExpr
|
||||
> extract = try (keyword_ "extract") >>
|
||||
> parens (makeOp <$> identifierString
|
||||
> <*> (keyword_ "from"
|
||||
> *> scalarExpr'))
|
||||
> where makeOp n e = SpecialOp "extract" [Iden n, e]
|
||||
|
||||
> inSuffix :: ScalarExpr -> P ScalarExpr
|
||||
> inSuffix e =
|
||||
> In
|
||||
|
@ -289,7 +296,7 @@ postgresql handles this
|
|||
> factor = choice [literal
|
||||
> ,scase
|
||||
> ,cast
|
||||
> --,extract
|
||||
> ,extract
|
||||
> ,subquery
|
||||
> ,prefixUnaryOp
|
||||
> ,try app
|
||||
|
|
|
@ -35,6 +35,11 @@ back into SQL source text. It attempts to format the output nicely.
|
|||
> ,text nm <+> scalarExpr b
|
||||
> ,text "and" <+> scalarExpr c]
|
||||
|
||||
> scalarExpr (SpecialOp "extract" [a,n]) =
|
||||
> text "extract" <> parens (scalarExpr a
|
||||
> <+> text "from"
|
||||
> <+> scalarExpr n)
|
||||
|
||||
> scalarExpr (SpecialOp nm es) =
|
||||
> text nm <+> parens (commaSep $ map scalarExpr es)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue