hasql 0.19.15.2 → 0.19.16
raw patch · 4 files changed
+74/−10 lines, 4 filesdep +rerebasedep ~QuickCheckdep ~hashtablesdep ~textPVP ok
version bump matches the API change (PVP)
Dependencies added: rerebase
Dependency ranges changed: QuickCheck, hashtables, text, vector
API changes (from Hackage documentation)
Files
- hasql.cabal +8/−8
- library/Hasql/Encoders.hs +3/−0
- tasty/Main.hs +61/−0
- tasty/Main/Prelude.hs +2/−2
hasql.cabal view
@@ -1,7 +1,7 @@ name: hasql version:- 0.19.15.2+ 0.19.16 category: Hasql, Database, PostgreSQL synopsis:@@ -82,11 +82,11 @@ dlist >= 0.7 && < 0.9, aeson >= 0.7 && < 2, uuid == 1.3.*,- vector >= 0.10 && < 0.12,+ vector >= 0.10 && < 0.13, time >= 1.4 && < 2,- hashtables >= 1.1 && < 1.3,+ hashtables >= 1.1 && < 2, scientific >= 0.2 && < 0.4,- text >= 1 && < 1.3,+ text >= 1 && < 2, bytestring >= 0.10 && < 0.11, hashable >= 1.2 && < 1.3, -- control:@@ -131,11 +131,11 @@ tasty-smallcheck == 0.8.*, tasty-hunit == 0.9.*, quickcheck-instances >= 0.3.11 && < 0.4,- QuickCheck >= 2.8.1 && < 2.9,+ QuickCheck >= 2.8.1 && < 2.10, -- general: data-default-class,- -- base,- rebase+ -- + rerebase < 2 test-suite threads-test@@ -158,7 +158,7 @@ build-depends: -- database: hasql,- -- base,+ -- rebase
library/Hasql/Encoders.hs view
@@ -488,6 +488,9 @@ -- >x = -- > array (arrayDimension foldl' (arrayDimension foldl' (arrayValue int8))) -- +-- Please note that the PostgreSQL __IN__ keyword does not "accept" an array, but rather a syntactical list of+-- values, thus this encoder is not suited for that. Use a **field** = ANY($1) query instead.+-- newtype Array a = Array (Array.Array a)
tasty/Main.hs view
@@ -22,6 +22,42 @@ localOption (NumThreads 1) $ testGroup "All tests" [+ testCase "IN simulation" $+ let+ query =+ Query.statement "select true where 1 = any ($1)" encoder decoder True+ where+ encoder =+ Encoders.value (Encoders.array (Encoders.arrayDimension foldl' (Encoders.arrayValue Encoders.int8)))+ decoder =+ fmap (maybe False (const True)) (Decoders.maybeRow (Decoders.value Decoders.bool))+ session =+ do+ result1 <- Session.query [1, 2] query+ result2 <- Session.query [2, 3] query+ return (result1, result2)+ in do+ x <- Connection.with (Session.run session)+ assertEqual (show x) (Right (Right (True, False))) x+ ,+ testCase "NOT IN simulation" $+ let+ query =+ Query.statement "select true where 3 <> all ($1)" encoder decoder True+ where+ encoder =+ Encoders.value (Encoders.array (Encoders.arrayDimension foldl' (Encoders.arrayValue Encoders.int8)))+ decoder =+ fmap (maybe False (const True)) (Decoders.maybeRow (Decoders.value Decoders.bool))+ session =+ do+ result1 <- Session.query [1, 2] query+ result2 <- Session.query [2, 3] query+ return (result1, result2)+ in do+ x <- Connection.with (Session.run session)+ assertEqual (show x) (Right (Right (True, False))) x+ , testCase "Composite decoding" $ let query =@@ -38,6 +74,31 @@ in do x <- Connection.with (Session.run session) assertEqual (show x) (Right (Right (1, True))) x+ ,+ testCase "Complex composite decoding" $+ let+ query =+ Query.statement sql encoder decoder True+ where+ sql =+ "select (1, true) as entity1, ('hello', 3) as entity2"+ encoder =+ Encoders.unit+ decoder =+ Decoders.singleRow $+ (,) <$> Decoders.value entity1 <*> Decoders.value entity2+ where+ entity1 =+ Decoders.composite $+ (,) <$> Decoders.compositeValue Decoders.int8 <*> Decoders.compositeValue Decoders.bool+ entity2 =+ Decoders.composite $+ (,) <$> Decoders.compositeValue Decoders.text <*> Decoders.compositeValue Decoders.int8+ session =+ Session.query () query+ in do+ x <- Connection.with (Session.run session)+ assertEqual (show x) (Right (Right ((1, True), ("hello", 3)))) x , testCase "Empty array" $ let
tasty/Main/Prelude.hs view
@@ -5,9 +5,9 @@ where --- base-prelude+-- rerebase --------------------------import Rebase.Prelude as Exports+import Prelude as Exports -- data-default-class -------------------------