mirror of
https://github.com/khibino/haskell-relational-record.git
synced 2024-12-01 13:52:12 +03:00
add withConnectionCommit.
This commit is contained in:
parent
9d2c52bec2
commit
94f1446bd7
@ -14,6 +14,7 @@
|
||||
module Database.HDBC.Session (
|
||||
-- * Bracketed session
|
||||
-- $bracketedSession
|
||||
withConnectionCommit,
|
||||
withConnectionIO, withConnectionIO',
|
||||
|
||||
withConnection,
|
||||
@ -79,6 +80,18 @@ withConnectionIO :: IConnection conn
|
||||
-> IO a -- ^ Result transaction action
|
||||
withConnectionIO = withConnection bracket id
|
||||
|
||||
-- | Same as 'withConnectionIO' other than issuing commit at the end of transaction body.
|
||||
-- In other words, the transaction with no exception is committed.
|
||||
withConnectionCommit :: IConnection conn
|
||||
=> IO conn -- ^ Connect action
|
||||
-> (conn -> IO a) -- ^ Transaction body
|
||||
-> IO a -- ^ Result transaction action
|
||||
withConnectionCommit conn body =
|
||||
withConnectionIO conn $ \c -> do
|
||||
x <- body c
|
||||
HDBC.commit c
|
||||
return x
|
||||
|
||||
-- | Same as 'withConnectionIO' other than wrapping transaction body in 'handleSqlError''.
|
||||
withConnectionIO' :: IConnection conn
|
||||
=> IO conn -- ^ Connect action
|
||||
|
Loading…
Reference in New Issue
Block a user