packages feed

pg-transact 0.3.1.1 → 0.3.2.0

raw patch · 7 files changed

+106/−20 lines, 7 filesdep +criteriondep +deepseqdep ~basedep ~tmp-postgresnew-uploaderPVP ok

version bump matches the API change (PVP)

Dependencies added: criterion, deepseq

Dependency ranges changed: base, tmp-postgres

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,5 @@+- 0.3.2.0+  - Support GHC 9.0.1 - 0.3.1.1   - #15 Remove unnecessary `ROLLBACK` call in `abort` 
LICENSE view
@@ -1,4 +1,4 @@-Copyright 2017 - Jonathan Fischoff+Copyright 2021 - Jonathan Fischoff  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
README.md view
@@ -1,2 +1,3 @@-# pg-transact-[![Travis CI Status](https://travis-ci.org/jfischoff/pg-transact.svg?branch=master)](http://travis-ci.org/jfischoff/pg-transact)+# pg-transact ![Hackage][shield] [![CI](https://github.com/jfischoff/pg-transact/actions/workflows/ci.yml/badge.svg)](https://github.com/jfischoff/pg-transact/actions/workflows/ci.yml)++[shield]: https://img.shields.io/hackage/v/pg-transact
+ benchmark/Main.hs view
@@ -0,0 +1,42 @@+import Control.DeepSeq+import Control.Exception+import Criterion.Main hiding (defaultConfig)+import qualified Database.Postgres.Temp as Temp+import qualified Database.PostgreSQL.Simple as PS+import qualified Database.PostgreSQL.Simple.Transaction as PS+import Database.PostgreSQL.Transact++++data Once a = Once { unOnce :: a }++instance NFData (Once a) where+  rnf x = seq x ()++setup :: IO (Temp.Cache, Once Temp.DB, Once PS.Connection)+setup = do+  cacheInfo <- Temp.setupInitDbCache Temp.defaultCacheConfig+  let theConfig = Temp.defaultConfig <> Temp.cacheConfig cacheInfo+  (db, conn) <- bracketOnError (Temp.startConfig theConfig) (either mempty Temp.stop) $ \case+    Left e -> throwIO e+    Right db -> bracketOnError (PS.connectPostgreSQL $ Temp.toConnectionString db) PS.close $ \conn ->+      pure (db, conn)++  pure (cacheInfo, Once db, Once conn)++cleanup :: (Temp.Cache, Once Temp.DB, Once PS.Connection) -> IO ()+cleanup (x, Once y, Once z) = do+  Temp.cleanupInitDbCache x+  Temp.stop y+  PS.close z++setupWith :: (PS.Connection -> Benchmark) -> Benchmark+setupWith f = envWithCleanup setup cleanup $ \ ~(_, _, Once x) -> f x++main :: IO ()+main = defaultMain+  [ setupWith $ \conn -> bench "rollback" $ whnfIO $+      runDBT (rollback $ pure ()) PS.ReadCommitted conn+  , setupWith $ \conn -> bench "abort" $ whnfIO $+      handle (\Abort -> pure ()) $ runDBT (abort $ pure ()) PS.ReadCommitted conn+  ]
pg-transact.cabal view
@@ -1,25 +1,31 @@ name:                pg-transact-version:             0.3.1.1-synopsis: A postgresql-simple transaction monad-description: Another postgresql-simple transaction monad+version:             0.3.2.0+synopsis:            A postgresql-simple transaction monad+description:         A postgresql-simple transaction monad homepage:            https://github.com/jfischoff/pg-transact#readme license:             BSD3 license-file:        LICENSE author:              Jonathan Fischoff maintainer:          jonathangfischoff@gmail.com-copyright:           2017 Jonathan Fischoff+copyright:           2021 Jonathan Fischoff category:            Web build-type:          Simple-extra-source-files: README.md-                  , CHANGELOG.md+extra-source-files:+    README.md+  , CHANGELOG.md cabal-version:       >=1.10   library-  default-extensions: TypeApplications+  default-extensions:+      TypeApplications+    , FlexibleContexts+    , GeneralizedNewtypeDeriving+    , RecordWildCards+    , OverloadedStrings   hs-source-dirs:      src   exposed-modules:     Database.PostgreSQL.Transact-  build-depends:       base >= 4.7 && < 5+  build-depends: base >= 4.7 && < 5                , postgresql-simple                , transformers                , monad-control@@ -28,6 +34,34 @@   ghc-options: -Wall   default-language:    Haskell2010 +benchmark benchmark+  type: exitcode-stdio-1.0+  main-is: Main.hs+  hs-source-dirs: benchmark+  default-language: Haskell2010+  ghc-options: -O2 -Wall -threaded -rtsopts -with-rtsopts=-N+  build-depends: base+    , criterion+    , deepseq+    , postgresql-simple+    , pg-transact+    , tmp-postgres+  default-extensions:+      ApplicativeDo+    , DeriveFunctor+    , DeriveGeneric+    , DerivingStrategies+    , DerivingVia+    , GeneralizedNewtypeDeriving+    , LambdaCase+    , OverloadedStrings+    , RankNTypes+    , RecordWildCards+    , ScopedTypeVariables+    , TemplateHaskell+    , TupleSections+    , ViewPatterns+ test-suite pg-transact-test   type:                exitcode-stdio-1.0   hs-source-dirs:      test@@ -45,6 +79,21 @@                , postgresql-libpq   ghc-options:         -threaded -rtsopts -with-rtsopts=-N   default-language:    Haskell2010+  default-extensions:+      DeriveFunctor+    , DeriveGeneric+    , DerivingStrategies+    , DerivingVia+    , GeneralizedNewtypeDeriving+    , LambdaCase+    , OverloadedStrings+    , RankNTypes+    , RecordWildCards+    , ScopedTypeVariables+    , TemplateHaskell+    , TupleSections+    , ViewPatterns+    , QuasiQuotes  source-repository head   type:     git
src/Database/PostgreSQL/Transact.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE FlexibleContexts, GeneralizedNewtypeDeriving, RecordWildCards, OverloadedStrings #-} module Database.PostgreSQL.Transact where import Control.Monad.Trans.Reader import qualified Database.PostgreSQL.Simple as Simple@@ -58,7 +57,7 @@     let setup = catch (restore act) $ \e -> do                   liftIO $ Simple.rollbackToSavepoint conn sp                     `catch` (\re -> if isNoTransaction re then pure () else throwM re)-                  if typeRep (Proxy @ Abort) == typeOf e+                  if typeRep (Proxy @Abort) == typeOf e                     then (throwM Abort)                     else unDBT $ handler e 
test/Database/PostgreSQL/TransactSpec.hs view
@@ -1,6 +1,3 @@-{-# LANGUAGE QuasiQuotes          #-}-{-# LANGUAGE DeriveDataTypeable   #-}-{-# LANGUAGE ScopedTypeVariables  #-} module Database.PostgreSQL.TransactSpec where  import           Control.Monad              (void)@@ -23,9 +20,6 @@ import qualified Control.Exception as E import           Control.Monad ((<=<)) --- import qualified Database.PostgreSQL.Simple.Internal as PS--- import qualified Database.PostgreSQL.LibPQ as PG- aroundAll :: forall a. ((a -> IO ()) -> IO ()) -> SpecWith a -> Spec aroundAll withFunc specWith = do   (var, stopper, asyncer) <- runIO $@@ -62,7 +56,6 @@     withConn db $ \conn -> do       void $ PS.execute_ conn $           [sql| CREATE TABLE fruit (name VARCHAR(100) PRIMARY KEY ) |]---      f conn `finally` (PS.withConnection conn (maybe (print "invalid") (print <=< PG.cancel) <=< PG.getCancel))       f conn