packages feed

hasql 1 → 1.1

raw patch · 4 files changed

+43/−11 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

hasql.cabal view
@@ -1,7 +1,7 @@ name:   hasql version:-  1+  1.1 category:   Hasql, Database, PostgreSQL synopsis:
library/Hasql/Encoders.hs view
@@ -359,14 +359,10 @@ -- Identifies the value with the PostgreSQL's \"unknown\" type, -- thus leaving it up to Postgres to infer the actual type of the value. -- --- The bytestring needs to be encoded according to the Postgres\' binary format--- of the type it expects.--- --- Essentially this is a low-level hook for encoding of values with custom codecs.--- The--- <http://hackage.haskell.org/package/postgresql-binary "postgresql-binary">--- library will provide you with the toolchain.--- +-- The value transimitted is any value encoded in the Postgres' Text data format.+-- For reference, see the+-- <https://www.postgresql.org/docs/10/static/protocol-overview.html#protocol-format-codes Formats and Format Codes>+-- section of the Postgres' documentation. {-# INLINABLE unknown #-} unknown :: Value ByteString unknown =
library/Hasql/Private/Encoders/Params.hs view
@@ -28,7 +28,7 @@     step (oid, bytesGetter) ~(oidList, bytesAndFormatList) =       (,)         (oid : oidList)-        (fmap (\bytes -> (bytes, A.Binary)) (bytesGetter integerDatetimes) : bytesAndFormatList)+        (fmap (\bytes -> (bytes, format oid)) (bytesGetter integerDatetimes) : bytesAndFormatList)  run'' :: Params a -> a -> Bool -> [Maybe (A.Oid, ByteString, A.Format)] run'' (Params (Op op)) params integerDatetimes =@@ -39,7 +39,12 @@       mapping a : b       where         mapping (oid, bytesGetter) =-          (,,) <$> pure oid <*> bytesGetter integerDatetimes <*> pure A.Binary+          (,,) <$> pure oid <*> bytesGetter integerDatetimes <*> pure (format oid)++format :: A.Oid -> A.Format+format oid = case oid of+  A.Oid 705 -> A.Text -- is unknown+  _         -> A.Binary  value :: C.Value a -> Params a value =
tasty/Main.hs view
@@ -305,6 +305,37 @@             in DSL.query "ok" query       in actualIO >>= assertEqual "" (Right True)     ,+    testCase "Textual Unknown" $+    let+      actualIO =+        DSL.session $ do+          let+            query =+              Query.statement sql mempty Decoders.unit True+              where+                sql =+                  "create or replace function overloaded(a int, b int) returns int as $$ select a + b $$ language sql;"+            in DSL.query () query+          let+            query =+              Query.statement sql mempty Decoders.unit True+              where+                sql =+                  "create or replace function overloaded(a text, b text, c text) returns text as $$ select a || b || c $$ language sql;"+            in DSL.query () query+          let+            query =+              Query.statement sql encoder decoder True+              where+                sql =+                  "select overloaded($1, $2) || overloaded($3, $4, $5)"+                decoder =+                  (Decoders.singleRow (Decoders.value (Decoders.text)))+                encoder =+                  contramany (Encoders.value Encoders.unknown)+            in DSL.query ["1", "2", "4", "5", "6"] query+      in actualIO >>= assertEqual "" (Right "3456")+    ,     testCase "Enum" $     let       actualIO =