@@ -90,6 +90,7 @@ import System.Environment (getEnvironment)
9090
9191import Database.Persist.Sql
9292import Database.Persist.SqlBackend
93+ import Database.Persist.SqlBackend.StatementCache
9394import qualified Database.Persist.Sql.Util as Util
9495
9596-- | A @libpq@ connection string. A simple example of connection
@@ -327,22 +328,22 @@ openSimpleConn = openSimpleConnWithVersion getServerVersion
327328-- @since 2.9.1
328329openSimpleConnWithVersion :: (PG. Connection -> IO (Maybe Double )) -> LogFunc -> PG. Connection -> IO SqlBackend
329330openSimpleConnWithVersion getVerDouble logFunc conn = do
330- smap <- makeSimpleStatementCache
331+ smap <- mkSimpleStatementCache
331332 serverVersion <- oldGetVersionToNew getVerDouble conn
332333 return $ createBackend logFunc serverVersion smap conn
333334
334335-- | Create the backend given a logging function, server version, mutable statement cell,
335336-- and connection.
336337createBackend :: LogFunc -> NonEmpty Word
337- -> StatementCache -> PG. Connection -> SqlBackend
338+ -> MkStatementCache -> PG. Connection -> SqlBackend
338339createBackend logFunc serverVersion smap conn =
339340 maybe id setConnPutManySql (upsertFunction putManySql serverVersion) $
340341 maybe id setConnUpsertSql (upsertFunction upsertSql' serverVersion) $
341342 setConnInsertManySql insertManySql' $
342343 maybe id setConnRepsertManySql (upsertFunction repsertManySql serverVersion) $
343344 mkSqlBackend MkSqlBackendArgs
344345 { connPrepare = prepare' conn
345- , connStmtMap = smap
346+ , connStmtMap = mkStatementCache smap
346347 , connInsertSql = insertSql'
347348 , connClose = PG. close conn
348349 , connMigrateSql = migrate'
@@ -362,7 +363,6 @@ createBackend logFunc serverVersion smap conn =
362363 , connRDBMS = " postgresql"
363364 , connLimitOffset = decorateSQLWithLimitOffset " LIMIT ALL"
364365 , connLogFunc = logFunc
365- , connStatementMiddleware = const pure
366366 }
367367
368368prepare' :: PG. Connection -> Text -> IO Statement
@@ -1603,7 +1603,7 @@ data PostgresConfHooks = PostgresConfHooks
16031603 -- The default implementation does nothing.
16041604 --
16051605 -- @since 2.11.0
1606- , pgConfHooksCreateStatementCache :: IO StatementCache
1606+ , pgConfHooksCreateStatementCache :: IO MkStatementCache
16071607 }
16081608
16091609-- | Default settings for 'PostgresConfHooks'. See the individual fields of 'PostgresConfHooks' for the default values.
@@ -1613,7 +1613,7 @@ defaultPostgresConfHooks :: PostgresConfHooks
16131613defaultPostgresConfHooks = PostgresConfHooks
16141614 { pgConfHooksGetServerVersion = getServerVersionNonEmpty
16151615 , pgConfHooksAfterCreate = const $ pure ()
1616- , pgConfHooksCreateStatementCache = makeSimpleStatementCache
1616+ , pgConfHooksCreateStatementCache = mkSimpleStatementCache
16171617 }
16181618
16191619
@@ -1695,7 +1695,7 @@ mockMigrate allDefs _ entity = fmap (fmap $ map showAlterDb) $ do
16951695-- with the difference that an actual database is not needed.
16961696mockMigration :: Migration -> IO ()
16971697mockMigration mig = do
1698- smap <- makeSimpleStatementCache
1698+ smap <- mkStatementCache <$> mkSimpleStatementCache
16991699 let sqlbackend =
17001700 mkSqlBackend MkSqlBackendArgs
17011701 { connPrepare = \ _ -> do
@@ -1719,7 +1719,6 @@ mockMigration mig = do
17191719 , connRDBMS = undefined
17201720 , connLimitOffset = undefined
17211721 , connLogFunc = undefined
1722- , connStatementMiddleware = const pure
17231722 }
17241723 result = runReaderT $ runWriterT $ runWriterT mig
17251724 resp <- result sqlbackend
0 commit comments