Skip to content

Commit

Permalink
Merge minor into master
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Sep 13, 2024
2 parents f033b12 + 34c540d commit 43138e4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion hasql.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: hasql
version: 1.8.0.2
version: 1.8.1
category: Hasql, Database, PostgreSQL
synopsis: Fast PostgreSQL driver with a flexible mapping API
description:
Expand Down Expand Up @@ -75,6 +75,7 @@ common base
StandaloneDeriving
StrictData
TupleSections
TypeApplications
TypeFamilies
TypeOperators

Expand Down
15 changes: 14 additions & 1 deletion library/Hasql/Session/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Hasql.Encoders.All qualified as Encoders
import Hasql.Encoders.Params qualified as Encoders.Params
import Hasql.Errors
import Hasql.IO qualified as IO
import Hasql.LibPq14 qualified as Pq
import Hasql.Pipeline.Core qualified as Pipeline
import Hasql.Prelude
import Hasql.Statement qualified as Statement
Expand All @@ -22,8 +23,20 @@ newtype Session a
-- Executes a bunch of commands on the provided connection.
run :: Session a -> Connection.Connection -> IO (Either SessionError a)
run (Session impl) connection =
runExceptT
handle @SomeException onExc
$ runExceptT
$ runReaderT impl connection
where
onExc exc =
case connection of
Connection.Connection pqConnVar _ _ ->
withMVar pqConnVar onPqConn
where
onPqConn pqConn = do
Pq.transactionStatus pqConn >>= \case
Pq.TransIdle -> pure ()
_ -> Pq.reset pqConn
throwIO exc

-- |
-- Possibly a multi-statement query,
Expand Down

0 comments on commit 43138e4

Please sign in to comment.