hasql 0.2.0 → 0.2.1
raw patch · 3 files changed
+72/−2 lines, 3 filesdep +scientificdep ~base-preludePVP ok
version bump matches the API change (PVP)
Dependencies added: scientific
Dependency ranges changed: base-prelude
API changes (from Hackage documentation)
Files
- hasql.cabal +27/−1
- library/Hasql/RowParser.hs +11/−1
- postgres-tests/Main.hs +34/−0
hasql.cabal view
@@ -1,7 +1,7 @@ name: hasql version:- 0.2.0+ 0.2.1 synopsis: A minimalistic general high level API for relational databases description:@@ -140,6 +140,32 @@ HTF == 0.12.*, hasql == 0.2.*, hasql-backend == 0.2.*,+ base-prelude == 0.1.*,+ base >= 4.5 && < 4.8+++test-suite postgres-tests+ type: + exitcode-stdio-1.0+ hs-source-dirs: + postgres-tests+ main-is: + Main.hs+ ghc-options:+ -threaded+ "-with-rtsopts=-N"+ -funbox-strict-fields+ default-extensions:+ Arrows, BangPatterns, ConstraintKinds, DataKinds, DefaultSignatures, DeriveDataTypeable, DeriveFunctor, DeriveGeneric, EmptyDataDecls, FlexibleContexts, FlexibleInstances, FunctionalDependencies, GADTs, GeneralizedNewtypeDeriving, ImpredicativeTypes, LambdaCase, LiberalTypeSynonyms, MagicHash, MultiParamTypeClasses, MultiWayIf, NoImplicitPrelude, NoMonomorphismRestriction, OverloadedStrings, PatternGuards, ParallelListComp, QuasiQuotes, RankNTypes, RecordWildCards, ScopedTypeVariables, StandaloneDeriving, TemplateHaskell, TupleSections, TypeFamilies, TypeOperators, UnboxedTuples+ default-language:+ Haskell2010+ build-depends:+ HTF == 0.12.*,+ hasql-postgres == 0.7.*,+ hasql == 0.2.*,+ scientific == 0.3.*,+ transformers >= 0.2 && < 0.5,+ mtl-prelude < 3, base-prelude == 0.1.*, base >= 4.5 && < 4.8
library/Hasql/RowParser.hs view
@@ -38,7 +38,17 @@ where rowVarName = mkName "row" e =- THUtil.applicativeE (ConE (tupleDataName arity)) lookups+ THUtil.purify $+ [|+ let actualLength = Vector.length $(varE rowVarName)+ expectedLength = $(litE (IntegerL $ fromIntegral arity))+ in if actualLength == expectedLength+ then $(pure $ THUtil.applicativeE (ConE (tupleDataName arity)) lookups)+ else Left $ fromString $ ($ "") $+ showString "Inappropriate row length: " . shows actualLength .+ showString ", expecting: " . shows expectedLength . + showString " instead"+ |] where lookups = do i <- [0 .. pred arity]
+ postgres-tests/Main.hs view
@@ -0,0 +1,34 @@+{-# OPTIONS_GHC -F -pgmF htfpp #-}+import BasePrelude+import MTLPrelude+import Test.Framework+import qualified Hasql as H+import qualified Hasql.Postgres as HP+++main = + htfMain $ htf_thisModulesTests++test_wrongRowParserArity =+ flip assertThrowsIO (\case H.UnparsableRow _ -> True; _ -> False) $+ session $ do+ H.tx Nothing $ do+ H.unit [H.q|DROP TABLE IF EXISTS data|]+ H.unit [H.q|CREATE TABLE data (+ field1 DECIMAL NOT NULL,+ field2 BIGINT NOT NULL,+ PRIMARY KEY (field1)+ )|]+ H.unit [H.q|INSERT INTO data (field1, field2) VALUES (0, 0)|]+ mrow :: Maybe (Double, Int64, String) <- + H.tx Nothing $ + H.single $ [H.q|SELECT * FROM data|]+ return ()+++session :: H.Session HP.Postgres IO r -> IO r+session =+ H.session backendSettings poolSettings+ where+ backendSettings = HP.Postgres "localhost" 5432 "postgres" "" "postgres"+ poolSettings = fromJust $ H.sessionSettings 6 30