1
Fork 0

add support for functions in tablerefs

This commit is contained in:
Jake Wheat 2013-12-17 12:33:33 +02:00
parent adfeac8d16
commit d49b3ddb99
5 changed files with 15 additions and 6 deletions
Language/SQL/SimpleSQL

View file

@ -505,6 +505,8 @@ tref
> tref = nonJoinTref >>= optionSuffix joinTrefSuffix
> nonJoinTref = choice [try (TRQueryExpr <$> parens queryExpr)
> ,TRParens <$> parens tref
> ,try (TRFunction <$> identifierString
> <*> parens (commaSep scalarExpr))
> ,TRSimple <$> identifierString]
> >>= optionSuffix aliasSuffix
> aliasSuffix j =

View file

@ -182,6 +182,8 @@
> ,nest 5 $ vcat $ punctuate comma $ map tr ts]
> where
> tr (TRSimple t) = text t
> tr (TRFunction f as) =
> text f <> parens (commaSep $ map scalarExpr as)
> tr (TRAlias t a cs) =
> sep [tr t
> ,text "as" <+> text a

View file

@ -195,6 +195,8 @@ I'm not sure if this is valid syntax or not.
> | TRAlias TableRef String (Maybe [String])
> -- | from (query expr)
> | TRQueryExpr QueryExpr
> -- | from function(args)
> | TRFunction String [ScalarExpr]
> deriving (Eq,Show,Read)
TODO: add function table ref