Skip to content

Commit

Permalink
wrapConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Mar 3, 2013
1 parent a9334c4 commit 364af6c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions persistent-sqlite/Database/Persist/Sqlite.hs
Expand Up @@ -12,6 +12,7 @@ module Database.Persist.Sqlite
, module Database.Persist.GenericSql
, SqliteConf (..)
, runSqlite
, wrapConnection
) where

import Database.Persist hiding (Entity (..))
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion 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>
Expand Down

0 comments on commit 364af6c

Please sign in to comment.