Allow new hasql-transaction to do rollbacks

This commit is contained in:
Joe Nelson
2016-02-25 20:13:03 -08:00
parent de772b9246
commit f28b03f419
3 changed files with 3 additions and 8 deletions
+1 -6
View File
@@ -14,7 +14,6 @@ import PostgREST.Middleware
import PostgREST.Types (DbStructure)
import Control.Monad
import Control.Monad.Error.Class (catchError, throwError)
import Data.Monoid ((<>))
import Data.String.Conversions (cs)
import Data.Time.Clock.POSIX (getPOSIXTime)
@@ -96,9 +95,5 @@ postgrest conf dbStructure pool =
let handleReq = runWithClaims conf time (app dbStructure conf body) req
resp <- either pgErrResponse id <$> P.use pool
(rollbackOnError $ HT.run handleReq HT.ReadCommitted HT.Write)
(HT.run handleReq HT.ReadCommitted HT.Write)
respond resp
where
rollbackOnError :: H.Session a -> H.Session a
rollbackOnError = (`catchError` ((H.sql "rollback;" >>) . throwError))