Skip to content

Commit 990dff6

Browse files
committed
Merge pull request #5 from helium/feature/isolation-level
Add `runPGTransaction'` with isolation parameter
2 parents 86d3918 + 2f90951 commit 990dff6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Database/PostgreSQL/TransactionalStore.hs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module Database.PostgreSQL.TransactionalStore
77
( PGTransaction
88
, TransactionalStore (..)
99
, runPGTransaction
10+
, runPGTransaction'
1011
, query
1112
, query_
1213
, execute
@@ -22,6 +23,7 @@ import Control.Applicative
2223
import Control.Monad.Reader
2324
import Data.Int
2425
import qualified Database.PostgreSQL.Simple as Postgres
26+
import qualified Database.PostgreSQL.Simple.Transaction as Postgres.Transaction
2527
import Database.PostgreSQL.Simple.FromRow
2628
import Database.PostgreSQL.Simple.ToRow
2729

@@ -34,9 +36,15 @@ newtype PGTransaction a =
3436
, MonadReader Postgres.Connection
3537
)
3638

39+
runPGTransaction' :: MonadIO m
40+
=> Postgres.Transaction.IsolationLevel
41+
-> PGTransaction a
42+
-> Postgres.Connection -> m a
43+
runPGTransaction' isolation (PGTransaction pgTrans) conn =
44+
liftIO (Postgres.Transaction.withTransactionLevel isolation conn (runReaderT pgTrans conn))
45+
3746
runPGTransaction :: MonadIO m => PGTransaction a -> Postgres.Connection -> m a
38-
runPGTransaction (PGTransaction pgTrans) conn =
39-
liftIO (Postgres.withTransaction conn (runReaderT pgTrans conn))
47+
runPGTransaction = runPGTransaction' Postgres.Transaction.DefaultIsolationLevel
4048

4149
-- | Used to execute a `HeliumStore' `m' value inside of a transaction, with
4250
-- connection/state `a', with effects in `n'.

0 commit comments

Comments
 (0)