Skip to content

Commit

Permalink
Expose unsafeUnnullify and unsafeUnnullifyTable
Browse files Browse the repository at this point in the history
  • Loading branch information
shane-circuithub committed Sep 18, 2024
1 parent b86e397 commit 4eb4a89
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changelog.d/20240918_124205_shane.obrien.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Added

- Expose `unsafeUnnullify` and `unsafeUnnullifyTable` from `Rel8`.
2 changes: 2 additions & 0 deletions src/Rel8.hs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ module Rel8
, catNullTable
, nameNullTable
, toNullTable, toMaybeTable
, unsafeUnnullifyTable

-- ** Algebraic data types / sum types
-- $adts
Expand Down Expand Up @@ -184,6 +185,7 @@ module Rel8
, liftOpNull
, catNull
, coalesce
, unsafeUnnullify

-- ** Boolean operations
, DBEq
Expand Down
4 changes: 4 additions & 0 deletions src/Rel8/Expr/Null.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ nullify :: NotNull a => Expr a -> Expr (Maybe a)
nullify (Expr a) = Expr a


-- | Assume that a nullable column's value is non-null. If the column is
-- actually @null@, this will lead to runtime errors when you try to decode
-- the value into Haskell, so you should prefer to use 'Rel8.nullable'
-- unless you know what you're doing.
unsafeUnnullify :: Expr (Maybe a) -> Expr a
unsafeUnnullify (Expr a) = Expr a

Expand Down
1 change: 1 addition & 0 deletions src/Rel8/Table/Null.hs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ nullifyTable :: a -> NullTable Expr a
nullifyTable = NullTable . pure


-- | Assume that a 'NullTable' is non-null. Like 'Rel8.unsafeUnnullify'.
unsafeUnnullifyTable :: NullTable Expr a -> a
unsafeUnnullifyTable (NullTable a) = extract a

Expand Down

0 comments on commit 4eb4a89

Please sign in to comment.