add support for values
This commit is contained in:
parent
4330b3d7e0
commit
c52334943f
5 changed files with 18 additions and 4 deletions
Language/SQL/SimpleSQL
|
@ -599,7 +599,7 @@ and union, etc..
|
|||
> queryExpr :: P QueryExpr
|
||||
> queryExpr =
|
||||
> choice [with
|
||||
> ,select >>= optionSuffix queryExprSuffix]
|
||||
> ,choice [values,select] >>= optionSuffix queryExprSuffix]
|
||||
> where
|
||||
> select = try (keyword_ "select") >>
|
||||
> Select
|
||||
|
@ -612,6 +612,8 @@ and union, etc..
|
|||
> <*> option [] orderBy
|
||||
> <*> optionMaybe limit
|
||||
> <*> optionMaybe offset
|
||||
> values = try (keyword_ "values")
|
||||
> >> Values <$> commaSep (parens (commaSep scalarExpr))
|
||||
|
||||
> queryExprSuffix :: QueryExpr -> P QueryExpr
|
||||
> queryExprSuffix qe =
|
||||
|
|
|
@ -177,6 +177,9 @@
|
|||
> (vcat $ punctuate comma $ flip map withs $ \(n,q) ->
|
||||
> name n <+> text "as" <+> parens (queryExpr q))
|
||||
> ,queryExpr qe]
|
||||
> queryExpr (Values vs) =
|
||||
> text "values"
|
||||
> <+> nest 7 (commaSep (map (parens . commaSep . map scalarExpr) vs))
|
||||
|
||||
> selectList :: [(Maybe Name, ScalarExpr)] -> Doc
|
||||
> selectList is = commaSep $ map si is
|
||||
|
|
|
@ -159,6 +159,8 @@
|
|||
> ,qe2 :: QueryExpr
|
||||
> }
|
||||
> | With [(Name,QueryExpr)] QueryExpr
|
||||
> | Values [[ScalarExpr]]
|
||||
|
||||
> deriving (Eq,Show,Read)
|
||||
|
||||
TODO: add queryexpr parens to deal with e.g.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue