1
Fork 0

add support for nulls first/last

This commit is contained in:
Jake Wheat 2013-12-17 18:28:31 +02:00
parent e85ab8b831
commit ebe522b21d
7 changed files with 66 additions and 34 deletions
Language/SQL/SimpleSQL

View file

@ -260,13 +260,18 @@
> grpBy gs = sep [text "group by"
> ,nest 9 $ commaSep $ map scalarExpr gs]
> orderBy :: [(ScalarExpr,Direction)] -> Doc
> orderBy :: [OrderField] -> Doc
> orderBy [] = empty
> orderBy os = sep [text "order by"
> ,nest 9 $ commaSep $ map f os]
> where
> f (e,Asc) = scalarExpr e
> f (e,Desc) = scalarExpr e <+> text "desc"
> f (OrderField e d n) =
> scalarExpr e
> <+> (if d == Asc then empty else text "desc")
> <+> (case n of
> NullsOrderDefault -> empty
> NullsFirst -> text "nulls" <+> text "first"
> NullsLast -> text "nulls" <+> text "last")
= utils