Skip to content
Open
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
4 changes: 4 additions & 0 deletions persistent-mysql-haskell/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ChangeLog for `persistent-mysql-haskell`

## 0.6.1

- [#14](https://github.com/naushadh/persistent/pull/14) Loosened constraints around `SqlBackend`

## 0.6.0

- Port [#977](https://github.com/yesodweb/persistent/pull/977) from `persistent-mysql`: Support Stackage Nightly
Expand Down
19 changes: 11 additions & 8 deletions persistent-mysql-haskell/Database/Persist/MySQL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ import Data.String (fromString)
-- The pool is properly released after the action finishes using
-- it. Note that you should not use the given 'ConnectionPool'
-- outside the action since it may be already been released.
withMySQLPool :: (MonadLogger m, MonadUnliftIO m)
withMySQLPool :: (MonadLogger m, MonadUnliftIO m, IsPersistBackend backend, BaseBackend backend ~ SqlBackend, BackendCompatible SqlBackend backend)
=> MySQLConnectInfo
-- ^ Connection information.
-> Int
-- ^ Number of connections to be kept open in the pool.
-> (Pool SqlBackend -> m a)
-> (Pool backend -> m a)
-- ^ Action to be executed that uses the connection pool.
-> m a
withMySQLPool ci = withSqlPool $ open' ci
Expand All @@ -105,21 +105,21 @@ withMySQLPool ci = withSqlPool $ open' ci
-- | Create a MySQL connection pool. Note that it's your
-- responsibility to properly close the connection pool when
-- unneeded. Use 'withMySQLPool' for automatic resource control.
createMySQLPool :: (MonadUnliftIO m, MonadLogger m)
createMySQLPool :: (MonadUnliftIO m, MonadLogger m, IsPersistBackend backend, BaseBackend backend ~ SqlBackend, BackendCompatible SqlBackend backend)
=> MySQLConnectInfo
-- ^ Connection information.
-> Int
-- ^ Number of connections to be kept open in the pool.
-> m (Pool SqlBackend)
-> m (Pool backend)
createMySQLPool ci = createSqlPool $ open' ci


-- | Same as 'withMySQLPool', but instead of opening a pool
-- of connections, only one connection is opened.
withMySQLConn :: (MonadUnliftIO m, MonadLogger m)
withMySQLConn :: (MonadUnliftIO m, MonadLogger m, IsPersistBackend backend, BaseBackend backend ~ SqlBackend, BackendCompatible SqlBackend backend)
=> MySQLConnectInfo
-- ^ Connection information.
-> (SqlBackend -> m a)
-> (backend -> m a)
-- ^ Action to be executed that uses the connection.
-> m a
withMySQLConn = withSqlConn . open'
Expand All @@ -133,12 +133,15 @@ connect' (MySQLConnectInfo innerCi (Just tls))

-- | Internal function that opens a @persistent@ connection to the MySQL
-- server.
open' :: MySQLConnectInfo -> LogFunc -> IO SqlBackend
open' :: (IsPersistBackend backend, BaseBackend backend ~ SqlBackend)
=> MySQLConnectInfo
-> LogFunc
-> IO backend
open' ci@(MySQLConnectInfo innerCi _) logFunc = do
conn <- connect' ci
autocommit' conn False -- disable autocommit!
smap <- newIORef $ Map.empty
return . mkPersistBackend $ SqlBackend
return . mkPersistBackend $ projectBackend $ SqlBackend
{ connPrepare = prepare' conn
, connStmtMap = smap
, connInsertSql = insertSql'
Expand Down
2 changes: 1 addition & 1 deletion persistent-mysql-haskell/persistent-mysql-haskell.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: persistent-mysql-haskell
version: 0.6.0
version: 0.6.1
license: MIT
license-file: LICENSE
author: Naushadh <naushadh@protonmail.com>, Felipe Lessa <felipe.lessa@gmail.com>, Michael Snoyman
Expand Down