1
Fork 0

allow current_timestamp to be parsed, bump version

This commit is contained in:
Jake Wheat 2019-08-31 10:08:02 +01:00
parent 9f4a457a4d
commit 3707a09cb8
4 changed files with 16 additions and 10 deletions

View file

@ -719,16 +719,10 @@ all the scalar expressions which start with an identifier
> idenExpr =
> -- todo: work out how to left factor this
> try (TypedLit <$> typeName <*> singleQuotesOnlyStringTok)
> <|> multisetSetFunction
> -- <|> multisetSetFunction
> <|> (try keywordFunction <**> app)
> <|> (names <**> option Iden app)
> where
> -- this is a special case because set is a reserved keyword
> -- and the names parser won't parse it
> multisetSetFunction =
> App [Name Nothing "set"] . (:[]) <$>
> (try (keyword_ "set" *> openParen)
> *> scalarExpr <* closeParen)
> keywordFunction =
> let makeKeywordFunction x = if map toLower x `elem` keywordFunctionNames
> then return [Name Nothing x]
@ -783,6 +777,7 @@ all the scalar expressions which start with an identifier
> ,"regr_syy"
> ,"row"
> ,"row_number"
> ,"set"
> ,"some"
> ,"stddev_pop"
> ,"stddev_samp"
@ -2293,7 +2288,7 @@ not, leave them unreserved for now
> ,"current_row"
> ,"current_schema"
> ,"current_time"
> ,"current_timestamp"
> --,"current_timestamp"
> ,"current_transform_group_for_type"
> --,"current_user"
> ,"cursor"

7
TODO
View file

@ -33,7 +33,12 @@ themselves
review main missing sql bits - focus on more mainstream things
could also review main dialects
review the dialect support implementation
** review the dialect support implementation
-> how to create your own dialects
especially how to override the reserved keyword list easily
make a list of the current dialect specific things
review the reserved word handling and make some more tests
add negative parsing tests for things that should fail
syntax from hssqlppp:

View file

@ -1,5 +1,5 @@
name: simple-sql-parser
version: 0.5.0
version: 0.5.1
synopsis: A parser for SQL.
description:

View file

@ -13,6 +13,12 @@ query expressions from one string.
> ,("select 1;",[ms])
> ,("select 1;select 1",[ms,ms])
> ,(" select 1;select 1; ",[ms,ms])
> ,("SELECT CURRENT_TIMESTAMP;"
> ,[SelectStatement $ makeSelect
> {qeSelectList = [(Iden [Name Nothing "CURRENT_TIMESTAMP"],Nothing)]}])
> ,("SELECT \"CURRENT_TIMESTAMP\";"
> ,[SelectStatement $ makeSelect
> {qeSelectList = [(Iden [Name (Just ("\"","\"")) "CURRENT_TIMESTAMP"],Nothing)]}])
> ]
> where
> ms = SelectStatement $ makeSelect {qeSelectList = [(NumLit "1",Nothing)]}