mirror of
https://github.com/nikita-volkov/hasql.git
synced 2024-11-26 23:33:02 +03:00
Fix the Composite decoder
This commit is contained in:
parent
a802f907a4
commit
08564ab360
@ -1,7 +1,7 @@
|
|||||||
name:
|
name:
|
||||||
hasql
|
hasql
|
||||||
version:
|
version:
|
||||||
0.19.15.1
|
0.19.15.2
|
||||||
category:
|
category:
|
||||||
Hasql, Database, PostgreSQL
|
Hasql, Database, PostgreSQL
|
||||||
synopsis:
|
synopsis:
|
||||||
@ -74,7 +74,7 @@ library
|
|||||||
-- parsing:
|
-- parsing:
|
||||||
attoparsec >= 0.10 && < 0.14,
|
attoparsec >= 0.10 && < 0.14,
|
||||||
-- database:
|
-- database:
|
||||||
postgresql-binary >= 0.9 && < 0.10,
|
postgresql-binary >= 0.9.1.1 && < 0.10,
|
||||||
postgresql-libpq == 0.9.*,
|
postgresql-libpq == 0.9.*,
|
||||||
-- builders:
|
-- builders:
|
||||||
bytestring-tree-builder >= 0.2.5 && < 0.3,
|
bytestring-tree-builder >= 0.2.5 && < 0.3,
|
||||||
|
@ -22,6 +22,23 @@ tree =
|
|||||||
localOption (NumThreads 1) $
|
localOption (NumThreads 1) $
|
||||||
testGroup "All tests"
|
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" $
|
testCase "Empty array" $
|
||||||
let
|
let
|
||||||
io =
|
io =
|
||||||
@ -334,6 +351,6 @@ tree =
|
|||||||
let
|
let
|
||||||
actualIO =
|
actualIO =
|
||||||
DSL.session $ DSL.query () $ Queries.selectList
|
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
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user