tweak some of the pretty printing
This commit is contained in:
parent
730b8a7f0a
commit
97189fb802
|
@ -60,7 +60,10 @@ back into SQL source text. It attempts to format the output nicely.
|
||||||
> <+> orderBy od)
|
> <+> orderBy od)
|
||||||
|
|
||||||
> scalarExpr (SpecialOp nm [a,b,c]) | nm `elem` ["between", "not between"] =
|
> scalarExpr (SpecialOp nm [a,b,c]) | nm `elem` ["between", "not between"] =
|
||||||
> scalarExpr a <+> text nm <+> scalarExpr b <+> text "and" <+> scalarExpr c
|
> sep [scalarExpr a
|
||||||
|
> ,text nm <+> scalarExpr b
|
||||||
|
> ,nest (length nm + 1)
|
||||||
|
> $ text "and" <+> scalarExpr c]
|
||||||
|
|
||||||
> scalarExpr (SpecialOp "extract" [a,n]) =
|
> scalarExpr (SpecialOp "extract" [a,n]) =
|
||||||
> text "extract" <> parens (scalarExpr a
|
> text "extract" <> parens (scalarExpr a
|
||||||
|
@ -93,13 +96,14 @@ back into SQL source text. It attempts to format the output nicely.
|
||||||
> scalarExpr e0 <+> text f <+> scalarExpr e1
|
> scalarExpr e0 <+> text f <+> scalarExpr e1
|
||||||
|
|
||||||
> scalarExpr (Case t ws els) =
|
> scalarExpr (Case t ws els) =
|
||||||
> sep [text "case" <+> maybe empty scalarExpr t
|
> sep $ [text "case" <+> maybe empty scalarExpr t]
|
||||||
> ,nest 5 (sep (map w ws
|
> ++ map w ws
|
||||||
> ++ maybeToList (fmap e els)))
|
> ++ maybeToList (fmap e els)
|
||||||
> ,text "end"]
|
> ++ [text "end"]
|
||||||
> where
|
> where
|
||||||
> w (t0,t1) = sep [text "when" <+> nest 5 (scalarExpr t0)
|
> w (t0,t1) =
|
||||||
> ,text "then" <+> nest 5 (scalarExpr t1)]
|
> text "when" <+> nest 5 (scalarExpr t0)
|
||||||
|
> <+> text "then" <+> nest 5 (scalarExpr t1)
|
||||||
> e el = text "else" <+> nest 5 (scalarExpr el)
|
> e el = text "else" <+> nest 5 (scalarExpr el)
|
||||||
> scalarExpr (Parens e) = parens $ scalarExpr e
|
> scalarExpr (Parens e) = parens $ scalarExpr e
|
||||||
> scalarExpr (Cast e (TypeName tn)) =
|
> scalarExpr (Cast e (TypeName tn)) =
|
||||||
|
@ -120,13 +124,13 @@ back into SQL source text. It attempts to format the output nicely.
|
||||||
> ) <+> parens (queryExpr qe)
|
> ) <+> parens (queryExpr qe)
|
||||||
|
|
||||||
> scalarExpr (In b se x) =
|
> scalarExpr (In b se x) =
|
||||||
> sep [scalarExpr se
|
> scalarExpr se <+>
|
||||||
> ,if b then empty else text "not"
|
> (if b then empty else text "not")
|
||||||
> ,text "in"
|
> <+> text "in"
|
||||||
> ,parens (nest (if b then 3 else 7) $
|
> <+> parens (nest (if b then 3 else 7) $
|
||||||
> case x of
|
> case x of
|
||||||
> InList es -> commaSep $ map scalarExpr es
|
> InList es -> commaSep $ map scalarExpr es
|
||||||
> InQueryExpr qe -> queryExpr qe)]
|
> InQueryExpr qe -> queryExpr qe)
|
||||||
|
|
||||||
= query expressions
|
= query expressions
|
||||||
|
|
||||||
|
@ -179,14 +183,14 @@ back into SQL source text. It attempts to format the output nicely.
|
||||||
> where
|
> where
|
||||||
> tr (TRSimple t) = text t
|
> tr (TRSimple t) = text t
|
||||||
> tr (TRAlias t a cs) =
|
> tr (TRAlias t a cs) =
|
||||||
> tr t <+> text "as" <+> text a
|
> sep [tr t
|
||||||
> <+> maybe empty (parens . commaSep . map text) cs
|
> ,text "as" <+> text a
|
||||||
|
> <+> maybe empty (parens . commaSep . map text) cs]
|
||||||
> tr (TRParens t) = parens $ tr t
|
> tr (TRParens t) = parens $ tr t
|
||||||
> tr (TRQueryExpr q) = parens $ queryExpr q
|
> tr (TRQueryExpr q) = parens $ queryExpr q
|
||||||
> tr (TRJoin t0 jt t1 jc) =
|
> tr (TRJoin t0 jt t1 jc) =
|
||||||
> sep [tr t0
|
> sep [tr t0
|
||||||
> ,joinText jt jc
|
> ,joinText jt jc <+> tr t1
|
||||||
> ,tr t1
|
|
||||||
> ,joinCond jc]
|
> ,joinCond jc]
|
||||||
> joinText jt jc =
|
> joinText jt jc =
|
||||||
> sep [case jc of
|
> sep [case jc of
|
||||||
|
|
Loading…
Reference in a new issue