Disable transactions for read-only requests
This commit is contained in:
+2
-2
@@ -18,7 +18,7 @@ import Text.Regex.TDFA ((=~))
|
||||
import qualified Data.ByteString.Char8 as BS
|
||||
import Network.Wai.Middleware.Cors (cors)
|
||||
|
||||
import Middleware(clientErrors, withSavepoint, authenticated)
|
||||
import Middleware(clientErrors, withSavepoint, authenticated, Environment(..))
|
||||
|
||||
import Dbapi (app, corsPolicy, AppConfig(..))
|
||||
import PgQuery(addUser)
|
||||
@@ -65,7 +65,7 @@ appWithFixture :: ActionWith Application -> IO ()
|
||||
appWithFixture action = withDatabaseConnection $ \c -> do
|
||||
runRaw c "begin;"
|
||||
action $ cors corsPolicy . clientErrors $
|
||||
(authenticated "dbapi_anonymous" . withSavepoint) app c
|
||||
(authenticated "dbapi_anonymous" . withSavepoint Test) app c
|
||||
rollback c
|
||||
|
||||
rangeHdrs :: ByteRange -> [Header]
|
||||
|
||||
@@ -4,7 +4,7 @@ import Test.Hspec
|
||||
|
||||
import Database.HDBC (runRaw, quickQuery, fromSql, SqlError)
|
||||
import SpecHelper (dbWithSchema)
|
||||
import Middleware (withSavepoint)
|
||||
import Middleware (withSavepoint, Environment(..))
|
||||
import PgQuery (insert)
|
||||
import Types(SqlRow(..))
|
||||
import Control.Exception(catch)
|
||||
@@ -24,7 +24,7 @@ spec = let
|
||||
|
||||
describe "withSavepoint" $
|
||||
it "allows partial rollback of request" $ \c -> do
|
||||
let app = withSavepoint dbErrApp c
|
||||
let app = withSavepoint Test dbErrApp c
|
||||
[[beforeCount]] <- quickQuery c "select count(*) from \"1\".items" []
|
||||
runRaw c "set role dbapi_anonymous"
|
||||
_ <- insert "1" "items" (SqlRow []) c
|
||||
|
||||
Reference in New Issue
Block a user