From e4cf232834cf8d9e3c5f5c9a618ff01debb79abc Mon Sep 17 00:00:00 2001 From: Teo Camarasu Date: Fri, 18 Oct 2024 11:45:23 +0100 Subject: [PATCH] fix: `JSONEncoded` should be of type `json` rather than `jsonb` Resolves #344 --- changelog.d/20241018_113208_teofilcamarasu_jsonb.md | 3 +++ src/Rel8/Type/JSONEncoded.hs | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 changelog.d/20241018_113208_teofilcamarasu_jsonb.md diff --git a/changelog.d/20241018_113208_teofilcamarasu_jsonb.md b/changelog.d/20241018_113208_teofilcamarasu_jsonb.md new file mode 100644 index 00000000..e2105bb2 --- /dev/null +++ b/changelog.d/20241018_113208_teofilcamarasu_jsonb.md @@ -0,0 +1,3 @@ +### Fixed + +- `JSONEncoded` should be encoded as `json` not `jsonb`. Resolves #344 diff --git a/src/Rel8/Type/JSONEncoded.hs b/src/Rel8/Type/JSONEncoded.hs index 1681a05d..df5c0f8e 100644 --- a/src/Rel8/Type/JSONEncoded.hs +++ b/src/Rel8/Type/JSONEncoded.hs @@ -1,4 +1,5 @@ {-# language StandaloneKindSignatures #-} +{-# language OverloadedStrings #-} module Rel8.Type.JSONEncoded ( JSONEncoded(..) ) where @@ -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 @@ -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