1
Fork 0

Introduced QEComment, constructor, likewise the VEComment constructor

This commit is contained in:
Han Joosten 2015-03-14 14:28:05 +01:00
parent 258eff5298
commit dc5ca57124
4 changed files with 22 additions and 25 deletions
Language/SQL/SimpleSQL

View file

@ -13,7 +13,7 @@ which have been changed to try to improve the layout of the output.
> import Language.SQL.SimpleSQL.Syntax
> import Text.PrettyPrint (render, vcat, text, (<>), (<+>), empty, parens,
> nest, Doc, punctuate, comma, sep, fsep, quotes,
> nest, Doc, punctuate, comma, sep, quotes,
> doubleQuotes, brackets,hcat)
> import Data.Maybe (maybeToList, catMaybes)
> import Data.List (intercalate)
@ -221,7 +221,7 @@ which have been changed to try to improve the layout of the output.
> valueExpr _ (NextValueFor ns) =
> text "next value for" <+> names ns
> valueExpr d (QEComment cmt v) =
> valueExpr d (VEComment cmt v) =
> vcat $ map comment cmt ++ [valueExpr d v]
> doubleUpQuotes :: String -> String
@ -314,9 +314,8 @@ which have been changed to try to improve the layout of the output.
= query expressions
> queryExpr :: Dialect -> QueryExpr -> Doc
> queryExpr dia (Select d sl fr wh gb hv od off fe cmt) =
> fsep $ map comment cmt++
> [sep [text "select"
> queryExpr dia (Select d sl fr wh gb hv od off fe) =
> sep [text "select"
> ,case d of
> SQDefault -> empty
> All -> text "all"
@ -329,7 +328,7 @@ which have been changed to try to improve the layout of the output.
> ,orderBy dia od
> ,me (\e -> text "offset" <+> valueExpr dia e <+> text "rows") off
> ,fetchFirst
> ]]
> ]
> where
> fetchFirst =
> me (\e -> if dia == MySQL
@ -337,9 +336,8 @@ which have been changed to try to improve the layout of the output.
> else text "fetch first" <+> valueExpr dia e
> <+> text "rows only") fe
> queryExpr dia (CombineQueryExpr q1 ct d c q2 cmt) =
> fsep $ map comment cmt++
> [sep [queryExpr dia q1
> queryExpr dia (CombineQueryExpr q1 ct d c q2) =
> sep [queryExpr dia q1
> ,text (case ct of
> Union -> "union"
> Intersect -> "intersect"
@ -351,7 +349,7 @@ which have been changed to try to improve the layout of the output.
> <+> case c of
> Corresponding -> text "corresponding"
> Respectively -> empty
> ,queryExpr dia q2]]
> ,queryExpr dia q2]
> queryExpr d (With rc withs qe) =
> text "with" <+> (if rc then text "recursive" else empty)
> <+> vcat [nest 5
@ -362,6 +360,8 @@ which have been changed to try to improve the layout of the output.
> text "values"
> <+> nest 7 (commaSep (map (parens . commaSep . map (valueExpr d)) vs))
> queryExpr _ (Table t) = text "table" <+> names t
> queryExpr d (QEComment cmt v) =
> vcat $ map comment cmt ++ [queryExpr d v]
> alias :: Alias -> Doc
@ -447,4 +447,4 @@ which have been changed to try to improve the layout of the output.
> me = maybe empty
> comment :: Comment -> Doc
> comment (Comment str) = text "/*" <+> text str <+> text "*/"
> comment (BlockComment str) = text "/*" <+> text str <+> text "*/"