add positional arg to the syntax and parser
This commit is contained in:
parent
64d3b742b4
commit
d8b351472f
|
@ -586,6 +586,11 @@ select x from t where x > :param
|
|||
> <$> hostParamTok
|
||||
> <*> optionMaybe (keyword "indicator" *> hostParamTok)]
|
||||
|
||||
== positional arg
|
||||
|
||||
> positionalArg :: Parser ValueExpr
|
||||
> positionalArg = PositionalArg <$> positionalArgTok
|
||||
|
||||
== parens
|
||||
|
||||
value expression parens, row ctor and scalar subquery
|
||||
|
@ -1238,6 +1243,7 @@ documenting/fixing.
|
|||
> term :: Parser ValueExpr
|
||||
> term = choice [simpleLiteral
|
||||
> ,parameter
|
||||
> ,positionalArg
|
||||
> ,star
|
||||
> ,parensExpr
|
||||
> ,caseExpr
|
||||
|
@ -2048,6 +2054,13 @@ It is only allowed when all the strings are quoted with ' atm.
|
|||
> L.PrefixedVariable c p -> Just (c:p)
|
||||
> _ -> Nothing)
|
||||
|
||||
> positionalArgTok :: Parser Int
|
||||
> positionalArgTok = mytoken (\tok ->
|
||||
> case tok of
|
||||
> L.PositionalArg p -> Just p
|
||||
> _ -> Nothing)
|
||||
|
||||
|
||||
> sqlNumberTok :: Bool -> Parser String
|
||||
> sqlNumberTok intOnly = mytoken (\tok ->
|
||||
> case tok of
|
||||
|
|
|
@ -52,6 +52,7 @@ which have been changed to try to improve the layout of the output.
|
|||
> valueExpr _ (Iden i) = names i
|
||||
> valueExpr _ Star = text "*"
|
||||
> valueExpr _ Parameter = text "?"
|
||||
> valueExpr _ (PositionalArg n) = text $ "$" ++ show n
|
||||
> valueExpr _ (HostParameter p i) =
|
||||
> text p
|
||||
> <+> me (\i' -> text "indicator" <+> text i') i
|
||||
|
|
|
@ -109,6 +109,7 @@
|
|||
> | Star
|
||||
|
||||
> | Parameter -- ^ Represents a ? in a parameterized query
|
||||
> | PositionalArg Int -- ^ Represents an e.g. $1 in a parameterized query
|
||||
> | HostParameter String (Maybe String) -- ^ represents a host
|
||||
> -- parameter, e.g. :a. The
|
||||
> -- Maybe String is for the
|
||||
|
|
|
@ -60,9 +60,9 @@ Tests for parsing value expressions
|
|||
> ]
|
||||
|
||||
> parameter :: TestItem
|
||||
> parameter = Group "parameter" $ map (uncurry (TestValueExpr ansi2011))
|
||||
> [("?", Parameter)
|
||||
> ]
|
||||
> parameter = Group "parameter"
|
||||
> [TestValueExpr ansi2011 "?" Parameter
|
||||
> ,TestValueExpr postgres "$13" $ PositionalArg 13]
|
||||
|
||||
|
||||
> dots :: TestItem
|
||||
|
|
Loading…
Reference in a new issue