1
Fork 0

fix extra 'as' when printing ctes

This commit is contained in:
Jake Wheat 2019-08-31 09:30:42 +01:00
parent ce0eeb392a
commit 9f4a457a4d
2 changed files with 10 additions and 2 deletions

View file

@ -1482,8 +1482,11 @@ allows offset and fetch in either order
> With <$> option False (True <$ keyword_ "recursive")
> <*> commaSep1 withQuery <*> queryExpr
> where
> withQuery = (,) <$> (fromAlias <* keyword_ "as")
> withQuery = (,) <$> (withAlias <* keyword_ "as")
> <*> parens queryExpr
> withAlias = Alias <$> name <*> columnAliases
> columnAliases = optionMaybe $ parens $ commaSep1 name
== query expression

View file

@ -360,8 +360,13 @@ which have been changed to try to improve the layout of the output.
> text "with" <+> (if rc then text "recursive" else empty)
> <+> vcat [nest 5
> (vcat $ punctuate comma $ flip map withs $ \(n,q) ->
> alias n <+> text "as" <+> parens (queryExpr d q))
> withAlias n <+> text "as" <+> parens (queryExpr d q))
> ,queryExpr d qe]
> where
> withAlias (Alias nm cols) = name nm
> <+> me (parens . commaSep . map name) cols
> queryExpr d (Values vs) =
> text "values"
> <+> nest 7 (commaSep (map (parens . commaSep . map (scalarExpr d)) vs))