1
Fork 0

add support for ? for parameterized queries

This commit is contained in:
Jake Wheat 2013-12-19 10:44:20 +02:00
parent 72d7b9428f
commit b68c116839
5 changed files with 18 additions and 0 deletions

View file

@ -78,6 +78,7 @@ the fixity code.
> -- TODO fix me
> (SpecialOpK {}) -> str ('v':show e)
> Iden {} -> str ('v':show e)
> Parameter -> str ('v':show e)
> StringLit {} -> str ('v':show e)
> NumLit {} -> str ('v':show e)
> App n es -> HSE.App (var ('f':name n)) $ ltoh es

View file

@ -137,6 +137,13 @@ in any scalar expression context.
> star :: P ScalarExpr
> star = Star <$ symbol "*"
== parameter
use in e.g. select * from t where a = ?
> parameter :: P ScalarExpr
> parameter = Parameter <$ symbol "?"
== function application, aggregates and windows
this represents anything which syntactically looks like regular C
@ -591,6 +598,7 @@ could at least do with some heavy explanation.
> factor :: P ScalarExpr
> factor = choice [literal
> ,parameter
> ,scase
> ,cast
> ,try specialOpKs

View file

@ -40,6 +40,7 @@
> <+> maybe empty (parens . text . show ) p
> scalarExpr (Iden i) = name i
> scalarExpr Star = text "*"
> scalarExpr Parameter = text "?"
> scalarExpr (App f es) = name f <> parens (commaSep (map scalarExpr es))

View file

@ -115,6 +115,7 @@
> -- | in list literal and in subquery, if the bool is false it
> -- means not in was used ('a not in (1,2)')
> | In Bool ScalarExpr InPredValue
> | Parameter -- ^ Represents a ? in a parameterized query
> deriving (Eq,Show,Read)
> -- | Represents an identifier name, which can be quoted or unquoted.