From 213e904ccaf4234941a71ba82d2df2880531d45f Mon Sep 17 00:00:00 2001 From: Sergiu Starciuc Date: Thu, 7 Dec 2023 19:51:37 +0300 Subject: [PATCH] Add Database.Persist.Sqlite.createSqlitePoolWithConfig (#1524) * Add Database.Persist.Sqlite.createSqlitePoolWithConfig * Update the Changelog.md file with a link to PR * Bump the version number from 2.13.2.0 to 2.13.4.0 --------- Co-authored-by: Matt von Hagen (Parsons) --- persistent-sqlite/ChangeLog.md | 4 ++++ persistent-sqlite/Database/Persist/Sqlite.hs | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/persistent-sqlite/ChangeLog.md b/persistent-sqlite/ChangeLog.md index 88c63f5a7..a34f179b3 100644 --- a/persistent-sqlite/ChangeLog.md +++ b/persistent-sqlite/ChangeLog.md @@ -2,6 +2,10 @@ ## 2.13.3.0 (unreleased) +* [#1524](https://github.com/yesodweb/persistent/pull/1524) + * Add Database.Persist.Sqlite.createSqlitePoolWithConfig to create a SQLite + connection pool with a connection string and ConnectionPoolConfig. + Using ConnectionPoolConfig, it is possible to set the connection idle timeout. * [#1486](https://github.com/yesodweb/persistent/pull/1486) * Add Database.Sqlite.open' which takes a ByteString * [#1522](https://github.com/yesodweb/persistent/pull/1522) diff --git a/persistent-sqlite/Database/Persist/Sqlite.hs b/persistent-sqlite/Database/Persist/Sqlite.hs index e5b1a3701..9deddbd28 100644 --- a/persistent-sqlite/Database/Persist/Sqlite.hs +++ b/persistent-sqlite/Database/Persist/Sqlite.hs @@ -30,6 +30,7 @@ module Database.Persist.Sqlite , withSqliteConnInfo , createSqlitePool , createSqlitePoolFromInfo + , createSqlitePoolWithConfig , module Database.Persist.Sql , SqliteConf (..) , SqliteConnectionInfo @@ -133,6 +134,15 @@ createSqlitePoolFromInfo :: (MonadLoggerIO m, MonadUnliftIO m) => SqliteConnectionInfo -> Int -> m (Pool SqlBackend) createSqlitePoolFromInfo connInfo = createSqlPool $ openWith const connInfo +-- | Create a pool of SQLite connections. +-- +-- @since 2.13.4.0 +createSqlitePoolWithConfig :: (MonadUnliftIO m, MonadLoggerIO m) + => Text -- ^ connection string + -> ConnectionPoolConfig -> m (Pool SqlBackend) +createSqlitePoolWithConfig connString = + createSqlPoolWithConfig (openWith const (conStringToInfo connString)) + -- | Run the given action with a connection pool. -- -- Like 'createSqlitePool', this should not be used with @:memory:@.