Skip to content

Commit

Permalink
Added ascNullsLast and descNullsFirst
Browse files Browse the repository at this point in the history
Fixes #560
  • Loading branch information
tomjaguarpaw committed Sep 1, 2022
1 parent 5f8d7f3 commit c52705b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
report it on [the issue
tracker](https://github.com/tomjaguarpaw/haskell-opaleye/issues/new).

* Added `ascNullsLast` and `descNullsFirst`.

## 0.9.3.3

* No externally visible changes
Expand Down
11 changes: 11 additions & 0 deletions src/Opaleye/Order.hs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ ascNullsFirst :: SqlOrd b => (a -> F.Field_ n b) -> O.Order a
ascNullsFirst = O.order HPQ.OrderOp { HPQ.orderDirection = HPQ.OpAsc
, HPQ.orderNulls = HPQ.NullsFirst }

-- | Specify an ascending ordering by the given expression.
-- (Any NULLs appear last)
ascNullsLast :: SqlOrd b => (a -> F.Field_ n b) -> O.Order a
ascNullsLast = O.order HPQ.OrderOp { HPQ.orderDirection = HPQ.OpAsc
, HPQ.orderNulls = HPQ.NullsLast }

-- | Specify an descending ordering by the given expression.
-- (Any NULLs appear first)
descNullsFirst :: SqlOrd b => (a -> F.Field_ n b) -> O.Order a
descNullsFirst = O.order HPQ.OrderOp { HPQ.orderDirection = HPQ.OpDesc
, HPQ.orderNulls = HPQ.NullsFirst }

-- | Specify an descending ordering by the given expression.
-- (Any NULLs appear last)
Expand Down

0 comments on commit c52705b

Please sign in to comment.