Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose unsafeUnnullify and unsafeUnnullifyTable #343

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading