Fix the Composite decoder

This commit is contained in:
Nikita Volkov 2016-10-01 15:34:44 +03:00
parent a802f907a4
commit 08564ab360
2 changed files with 20 additions and 3 deletions

View File

@ -1,7 +1,7 @@
name:
hasql
version:
0.19.15.1
0.19.15.2
category:
Hasql, Database, PostgreSQL
synopsis:
@ -74,7 +74,7 @@ library
-- parsing:
attoparsec >= 0.10 && < 0.14,
-- database:
postgresql-binary >= 0.9 && < 0.10,
postgresql-binary >= 0.9.1.1 && < 0.10,
postgresql-libpq == 0.9.*,
-- builders:
bytestring-tree-builder >= 0.2.5 && < 0.3,

View File

@ -22,6 +22,23 @@ tree =
localOption (NumThreads 1) $
testGroup "All tests"
[
testCase "Composite decoding" $
let
query =
Query.statement sql encoder decoder True
where
sql =
"select (1, true)"
encoder =
Encoders.unit
decoder =
Decoders.singleRow (Decoders.value (Decoders.composite ((,) <$> Decoders.compositeValue Decoders.int8 <*> Decoders.compositeValue Decoders.bool)))
session =
Session.query () query
in do
x <- Connection.with (Session.run session)
assertEqual (show x) (Right (Right (1, True))) x
,
testCase "Empty array" $
let
io =
@ -334,6 +351,6 @@ tree =
let
actualIO =
DSL.session $ DSL.query () $ Queries.selectList
in assertEqual "" (Right [(1, 2), (3, 4), (5, 6)]) =<< actualIO
in assertEqual "" (Right [(1, 2), (3, 4), (5, 6)]) =<< actualIO
]