Skip to content
Browse files

wrapConnection

  • Loading branch information...
1 parent a9334c4 commit 364af6c46d7c1928f094932952c75d65cd00d01f @snoyberg snoyberg committed Mar 3, 2013
Showing with 10 additions and 3 deletions.
  1. +9 −2 persistent-sqlite/Database/Persist/Sqlite.hs
  2. +1 −1 persistent-sqlite/persistent-sqlite.cabal
View
11 persistent-sqlite/Database/Persist/Sqlite.hs
@@ -12,6 +12,7 @@ module Database.Persist.Sqlite
, module Database.Persist.GenericSql
, SqliteConf (..)
, runSqlite
+ , wrapConnection
) where
import Database.Persist hiding (Entity (..))
@@ -37,6 +38,7 @@ import Data.Conduit
import qualified Data.Conduit.List as CL
import Control.Applicative
import Data.Int (Int64)
+import Control.Monad ((>=>))
createSqlitePool :: MonadIO m => Text -> Int -> m ConnectionPool
createSqlitePool s = createSqlPool $ open' s
@@ -52,8 +54,13 @@ withSqliteConn :: (MonadBaseControl IO m, MonadIO m)
withSqliteConn = withSqlConn . open'
open' :: Text -> IO Connection
-open' s = do
- conn <- Sqlite.open s
+open' = Sqlite.open >=> wrapConnection
+
+-- | Wrap up a raw 'Sqlite.Connection' as a Persistent SQL 'Connection'.
+--
+-- Since 1.1.5
+wrapConnection :: Sqlite.Connection -> IO Connection
+wrapConnection conn = do
smap <- newIORef $ Map.empty
return Connection
{ prepare = prepare' conn
View
2 persistent-sqlite/persistent-sqlite.cabal
@@ -1,5 +1,5 @@
name: persistent-sqlite
-version: 1.1.4.1
+version: 1.1.5
license: MIT
license-file: LICENSE
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.