Skip to content
This repository
Browse code

wrapConnection

  • Loading branch information...
commit 364af6c46d7c1928f094932952c75d65cd00d01f 1 parent a9334c4
Michael Snoyman snoyberg authored
11 persistent-sqlite/Database/Persist/Sqlite.hs
@@ -12,6 +12,7 @@ module Database.Persist.Sqlite
12 12 , module Database.Persist.GenericSql
13 13 , SqliteConf (..)
14 14 , runSqlite
  15 + , wrapConnection
15 16 ) where
16 17
17 18 import Database.Persist hiding (Entity (..))
@@ -37,6 +38,7 @@ import Data.Conduit
37 38 import qualified Data.Conduit.List as CL
38 39 import Control.Applicative
39 40 import Data.Int (Int64)
  41 +import Control.Monad ((>=>))
40 42
41 43 createSqlitePool :: MonadIO m => Text -> Int -> m ConnectionPool
42 44 createSqlitePool s = createSqlPool $ open' s
@@ -52,8 +54,13 @@ withSqliteConn :: (MonadBaseControl IO m, MonadIO m)
52 54 withSqliteConn = withSqlConn . open'
53 55
54 56 open' :: Text -> IO Connection
55   -open' s = do
56   - conn <- Sqlite.open s
  57 +open' = Sqlite.open >=> wrapConnection
  58 +
  59 +-- | Wrap up a raw 'Sqlite.Connection' as a Persistent SQL 'Connection'.
  60 +--
  61 +-- Since 1.1.5
  62 +wrapConnection :: Sqlite.Connection -> IO Connection
  63 +wrapConnection conn = do
57 64 smap <- newIORef $ Map.empty
58 65 return Connection
59 66 { prepare = prepare' conn
2  persistent-sqlite/persistent-sqlite.cabal
... ... @@ -1,5 +1,5 @@
1 1 name: persistent-sqlite
2   -version: 1.1.4.1
  2 +version: 1.1.5
3 3 license: MIT
4 4 license-file: LICENSE
5 5 author: Michael Snoyman <michael@snoyman.com>

0 comments on commit 364af6c

Please sign in to comment.
Something went wrong with that request. Please try again.