Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions persistent-sqlite/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog for persistent-sqlite

## 2.13.2

* [#1488](https://github.com/yesodweb/persistent/pull/1488)
* Add `openRawSqliteConn` for creating `RawSqlite SqlBackend` connections
that aren't automatically cleaned-up.

## 2.13.1.1

* [#1459](https://github.com/yesodweb/persistent/pull/1459)
Expand Down
19 changes: 18 additions & 1 deletion persistent-sqlite/Database/Persist/Sqlite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ module Database.Persist.Sqlite
, ForeignKeyViolation(..)
, checkForeignKeys
, RawSqlite
, openRawSqliteConn
, persistentBackend
, rawSqliteConnection
, withRawSqliteConnInfo
Expand Down Expand Up @@ -94,8 +95,8 @@ import qualified Data.Conduit.Combinators as C
import qualified Data.Conduit.List as CL
import Data.Foldable (toList)
import qualified Data.HashMap.Lazy as HashMap
import Data.Int (Int64)
import Data.IORef (newIORef)
import Data.Int (Int64)
import Data.Maybe
import Data.Pool (Pool)
import Data.Text (Text)
Expand Down Expand Up @@ -938,6 +939,22 @@ data RawSqlite backend = RawSqlite
, _rawSqliteConnection :: Sqlite.Connection -- ^ The underlying `Sqlite.Connection`
}

-- | Open a @'RawSqlite' 'SqlBackend'@ connection from a 'SqliteConnectionInfo'.
--
-- When using this function, the caller has to accept the responsibility of
-- cleaning up the resulting connection. To do this, use 'close' with the
-- 'rawSqliteConnection' - it's enough to simply drop the 'persistBackend'
-- afterwards.
--
-- @since 2.13.2
openRawSqliteConn
:: (MonadUnliftIO m, MonadLoggerIO m)
=> SqliteConnectionInfo
-> m (RawSqlite SqlBackend)
openRawSqliteConn connInfo = do
logFunc <- askLoggerIO
liftIO $ openWith RawSqlite connInfo logFunc

instance BackendCompatible b (RawSqlite b) where
projectBackend = _persistentBackend

Expand Down
2 changes: 1 addition & 1 deletion persistent-sqlite/persistent-sqlite.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: persistent-sqlite
version: 2.13.1.1
version: 2.13.2.0
license: MIT
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>
Expand Down