add support for nulls first/last
This commit is contained in:
parent
e85ab8b831
commit
ebe522b21d
7 changed files with 66 additions and 34 deletions
Language/SQL/SimpleSQL
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue