Skip to content

Commit

Permalink
fix: JSONEncoded should be of type json rather than jsonb
Browse files Browse the repository at this point in the history
Resolves #344
  • Loading branch information
TeofilC committed Oct 18, 2024
1 parent c482564 commit e4cf232
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelog.d/20241018_113208_teofilcamarasu_jsonb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Fixed

- `JSONEncoded` should be encoded as `json` not `jsonb`. Resolves #344
5 changes: 3 additions & 2 deletions src/Rel8/Type/JSONEncoded.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# language StandaloneKindSignatures #-}
{-# language OverloadedStrings #-}

module Rel8.Type.JSONEncoded ( JSONEncoded(..) ) where

Expand All @@ -12,7 +13,7 @@ import Prelude

-- rel8
import Rel8.Type ( DBType(..) )
import Rel8.Type.Information ( parseTypeInformation )
import Rel8.Type.Information ( TypeInformation(..), parseTypeInformation )


-- | A deriving-via helper type for column types that store a Haskell value
Expand All @@ -23,7 +24,7 @@ newtype JSONEncoded a = JSONEncoded { fromJSONEncoded :: a }


instance (FromJSON a, ToJSON a) => DBType (JSONEncoded a) where
typeInformation = parseTypeInformation f g typeInformation
typeInformation = parseTypeInformation f g typeInformation { typeName = "json"}
where
f = fmap JSONEncoded . parseEither parseJSON
g = toJSON . fromJSONEncoded

0 comments on commit e4cf232

Please sign in to comment.