packages feed

postgresql-binary 0.7.8 → 0.7.9

raw patch · 3 files changed

+31/−19 lines, 3 filesdep ~json-astdep ~rebase

Dependency ranges changed: json-ast, rebase

Files

library/PostgreSQL/Binary/Decoder.hs view
@@ -154,15 +154,27 @@ {-# INLINABLE jsonb #-} jsonb :: Decoder Aeson.Value jsonb =-  fn $ (=<<) decode . getBytes+  jsonb_bytes $ mapLeft fromString . Aeson.eitherDecodeStrict'++-- |+-- Given a function, which parses a plain UTF-8 JSON string encoded as a byte-array,+-- produces a decoder.+-- +-- For those wondering, yes,+-- JSONB is encoded as plain JSON string in the binary format of Postgres.+-- Sad, but true.+{-# INLINABLE jsonb_bytes #-}+jsonb_bytes :: (ByteString -> Either Text a) -> Decoder a+jsonb_bytes cont =+  getAllBytes >>= trimBytes >>= parseJSON   where-    decode =-      mapLeft fromString .-      Aeson.eitherDecodeStrict'-    getBytes =-      maybe (Left "Empty input") Right .-      fmap snd .-      ByteString.uncons+    getAllBytes =+      BinaryParser.remainders+    trimBytes =+      maybe (BinaryParser.failure "Empty input") return .+      fmap snd . ByteString.uncons+    parseJSON =+      either BinaryParser.failure return . cont   -- ** Textual
postgresql-binary.cabal view
@@ -1,7 +1,7 @@ name:   postgresql-binary version:-  0.7.8+  0.7.9 synopsis:   Encoders and decoders for the PostgreSQL's binary format description:@@ -117,7 +117,7 @@     QuickCheck >= 2.8.1 && < 2.9,     -- data:     aeson,-    json-ast == 0.1.*,+    json-ast == 0.2.*,     uuid == 1.3.*,     time >= 1.4 && < 2,     scientific >= 0.2 && < 0.4,@@ -133,7 +133,7 @@     conversion-text == 1.*,     either == 4.*,     transformers,-    rebase >= 0.1.4 && < 0.2,+    rebase >= 0.2.1 && < 0.3,     base  
tasty/Main/Gens.hs view
@@ -3,7 +3,7 @@ import Main.Prelude hiding (assert, isRight, isLeft, choose) import Test.QuickCheck hiding (vector) import Test.QuickCheck.Instances-import JSON.AST (JSON)+import JSONAST (JSON) import qualified Main.PTI as PTI import qualified Data.Scientific as Scientific import qualified Data.UUID as UUID@@ -13,7 +13,7 @@ import qualified PostgreSQL.Binary.Encoder as Encoder import qualified Data.Text as Text import qualified Data.Aeson as Aeson-import qualified JSON.AST+import qualified JSONAST   -- * Generators@@ -43,17 +43,17 @@         maxFreq =           6         null =-          pure JSON.AST.Null+          pure JSONAST.Null         bool =-          fmap JSON.AST.Bool arbitrary+          fmap JSONAST.Bool arbitrary         number =-          fmap JSON.AST.Number arbitrary+          fmap JSONAST.Number arbitrary         string =-          fmap JSON.AST.String text+          fmap JSONAST.String text         array =-          fmap JSON.AST.Array (vector (byDepth (succ depth)))+          fmap JSONAST.Array (vector (byDepth (succ depth)))         object =-          fmap JSON.AST.Object (hashMap text (byDepth (succ depth)))+          fmap JSONAST.Object (hashMap text (byDepth (succ depth)))  vector :: Gen a -> Gen (Vector a) vector element =