diff --git a/CHANGELOG.md b/CHANGELOG.md index 67e47b5..6dada14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [0.0.3.1] - 2023-09-28 +### Changed +- `FromValue` now can unpack DB `Int` as Haskell `Double`. +- Verbose error in TemplateHaskell converter when property of a node or a relationship can't be + unpacked. + ## [0.0.3.0] - 2023-08-17 ### Added - `IsString` instance for `Cond` and `Conds`. diff --git a/hasbolt-extras.cabal b/hasbolt-extras.cabal index e691898..632d120 100644 --- a/hasbolt-extras.cabal +++ b/hasbolt-extras.cabal @@ -1,5 +1,5 @@ name: hasbolt-extras -version: 0.0.3.0 +version: 0.0.3.1 synopsis: Extras for hasbolt library description: Extras for hasbolt library homepage: https://github.com/biocad/hasbolt-extras#readme diff --git a/src/Database/Bolt/Extras/Internal/Instances.hs b/src/Database/Bolt/Extras/Internal/Instances.hs index e33b6a9..701ecb7 100644 --- a/src/Database/Bolt/Extras/Internal/Instances.hs +++ b/src/Database/Bolt/Extras/Internal/Instances.hs @@ -19,7 +19,7 @@ import Database.Bolt.Extras.Internal.Types (FromValue (..), NodeLike ( NodeLikeProps (..), ToIsValue (..), ToValue (..)) import Database.Bolt.Extras.Utils (currentLoc) -import GHC.Float (double2Float, float2Double) +import GHC.Float (double2Float, float2Double, int2Double) import GHC.Stack (HasCallStack) @@ -80,6 +80,7 @@ instance FromValue Int where instance FromValue Double where fromValue (F doubleV) = doubleV + fromValue (I intV) = int2Double intV fromValue v = error $ $currentLoc ++ "could not unpack " ++ show v ++ " into Double" instance FromValue Float where diff --git a/src/Database/Bolt/Extras/Template/Internal/Converters.hs b/src/Database/Bolt/Extras/Template/Internal/Converters.hs index b9e4cd1..2adaa4f 100644 --- a/src/Database/Bolt/Extras/Template/Internal/Converters.hs +++ b/src/Database/Bolt/Extras/Template/Internal/Converters.hs @@ -323,7 +323,10 @@ getProp container (fieldName, fieldMaybe) | fieldMaybe && fieldName `notMember` where exactE v = case exactEither v of Right res -> res - Left err -> error $ show err + Left err -> error + $ "Could not unpack " + <> unpack fieldName <> ": " <> show err + <> ", value: " <> show v unpackError :: HasCallStack => Show c => c -> String -> a unpackError container label = error $ $currentLoc ++ " could not unpack " ++ label ++ " from " ++ show container