postgresql-binary 0.12.1.3 → 0.12.2
raw patch · 3 files changed
+15/−4 lines, 3 files
Files
- library/PostgreSQL/Binary/Decoding.hs +11/−0
- postgresql-binary.cabal +1/−1
- tasty/Main.hs +3/−3
library/PostgreSQL/Binary/Decoding.hs view
@@ -51,6 +51,7 @@ hstore, -- ** enum,+ refine, ) where @@ -537,3 +538,13 @@ failure ("No mapping for text \"" <> text <> "\"") onJust = pure++-- * Refining values+-------------------------++-- | Given additional constraints when+-- using an existing value decoder, produces+-- a decoder of that value.+{-# INLINE refine #-}+refine :: (a -> Either Text b) -> Value a -> Value b+refine fn m = m >>= (either failure pure . fn)
postgresql-binary.cabal view
@@ -1,7 +1,7 @@ name: postgresql-binary version:- 0.12.1.3+ 0.12.2 synopsis: Encoders and decoders for the PostgreSQL's binary format description:
tasty/Main.hs view
@@ -1,6 +1,6 @@ module Main where -import Main.Prelude hiding (assert, isRight, isLeft)+import Main.Prelude hiding (assert, isRight, isLeft, select) import Control.Monad.IO.Class import Test.QuickCheck.Instances import Test.Tasty@@ -101,14 +101,14 @@ let p = (,,) (PTI.oidPQ (PTI.ptiOID PTI.timestamptz)) ((A.encodingBytes . encoder) x) (LibPQ.Binary)- x = read "2011-09-28 00:17:25"+ x = read "2011-09-28 00:17:25Z" DB.unit "insert into a (b) values ($1)" [Just p] DB.unit "set timezone to 'Europe/Stockholm'" [] textual <- DB.oneRow "SELECT * FROM a" [] LibPQ.Text decoded <- fmap (B.valueParser decoder) (DB.oneRow "SELECT * FROM a" [] LibPQ.Binary) return (textual, decoded) HUnit.assertEqual "" ("2011-09-28 02:17:25+02") textual- HUnit.assertEqual "" (Right (read "2011-09-28 00:17:25")) decoded+ HUnit.assertEqual "" (Right (read "2011-09-28 00:17:25Z")) decoded , timeRoundtrip "timestamptz" (fmap Apx Gens.auto) PTI.timestamptz ((. unApx) . bool A.timestamptz_float A.timestamptz_int)