Run queries in a transaction again

This commit is contained in:
Joe Nelson
2016-01-24 18:09:19 -08:00
parent ac73e8d77b
commit 51f71eb53d
3 changed files with 26 additions and 2 deletions
+3 -1
View File
@@ -25,6 +25,7 @@ import PostgREST.Config (AppConfig(..))
import PostgREST.Middleware
import PostgREST.Error(pgErrResponse)
import PostgREST.Types
import PostgREST.QueryBuilder (inTransaction, Isolation(..))
dbString :: String
dbString = "postgres://postgrest_test_authenticator@localhost:5432/postgrest_test"
@@ -44,7 +45,8 @@ withApp config dbStructure c perform = do
perform $ defaultMiddle $ \req resp -> do
time <- getPOSIXTime
body <- strictRequestBody req
let handleReq = H.run (runWithClaims config time (app dbStructure config body) req)
let handleReq = H.run $ inTransaction ReadCommitted
(runWithClaims config time (app dbStructure config body) req)
resOrError <- handleReq c
either (resp . pgErrResponse) resp resOrError