packages feed

persistent-postgresql 2.1.2.2 → 2.1.3

raw patch · 3 files changed

+34/−8 lines, 3 filesdep ~base

Dependency ranges changed: base

Files

ChangeLog.md view
@@ -1,3 +1,8 @@+## 2.1.3++* Added a `Show` instance for `PostgresConf`.+* `createPostgresqlPoolModified` added, see [relevant mailing list discussion](https://groups.google.com/d/msg/yesodweb/qUXrEN_swEo/O0pFwqwQIdcJ)+ ## 2.1.2.1  Documentation typo fix
Database/Persist/Postgresql.hs view
@@ -12,6 +12,7 @@     ( withPostgresqlPool     , withPostgresqlConn     , createPostgresqlPool+    , createPostgresqlPoolModified     , module Database.Persist.Sql     , ConnectionString     , PostgresConf (..)@@ -88,7 +89,7 @@                    -- ^ Action to be executed that uses the                    -- connection pool.                    -> m a-withPostgresqlPool ci = withSqlPool $ open' ci+withPostgresqlPool ci = withSqlPool $ open' (const $ return ()) ci   -- | Create a PostgreSQL connection pool.  Note that it's your@@ -102,18 +103,38 @@                      -- ^ Number of connections to be kept open                      -- in the pool.                      -> m ConnectionPool-createPostgresqlPool ci = createSqlPool $ open' ci+createPostgresqlPool = createPostgresqlPoolModified (const $ return ()) +-- | Same as 'createPostgresqlPool', but additionally takes a callback function+-- for some connection-specific tweaking to be performed after connection+-- creation. This could be used, for example, to change the schema. For more+-- information, see:+--+-- <https://groups.google.com/d/msg/yesodweb/qUXrEN_swEo/O0pFwqwQIdcJ>+--+-- Since 2.1.3+createPostgresqlPoolModified+    :: (MonadIO m, MonadBaseControl IO m, MonadLogger m)+    => (PG.Connection -> IO ()) -- ^ action to perform after connection is created+    -> ConnectionString -- ^ Connection string to the database.+    -> Int -- ^ Number of connections to be kept open in the pool.+    -> m ConnectionPool+createPostgresqlPoolModified modConn ci = createSqlPool $ open' modConn ci  -- | Same as 'withPostgresqlPool', but instead of opening a pool -- of connections, only one connection is opened. withPostgresqlConn :: (MonadIO m, MonadBaseControl IO m, MonadLogger m)                    => ConnectionString -> (SqlBackend -> m a) -> m a-withPostgresqlConn = withSqlConn . open'+withPostgresqlConn = withSqlConn . open' (const $ return ()) -open' :: ConnectionString -> LogFunc -> IO SqlBackend-open' cstr logFunc = PG.connectPostgreSQL cstr >>= openSimpleConn logFunc+open' :: (PG.Connection -> IO ())+      -> ConnectionString -> LogFunc -> IO SqlBackend+open' modConn cstr logFunc = do+    conn <- PG.connectPostgreSQL cstr+    modConn conn+    openSimpleConn logFunc conn + -- | Generate a 'Connection' from a 'PG.Connection' openSimpleConn :: LogFunc -> PG.Connection -> IO SqlBackend openSimpleConn logFunc conn = do@@ -868,7 +889,7 @@       -- ^ The connection string.     , pgPoolSize :: Int       -- ^ How many connections should be held on the connection pool.-    }+    } deriving Show  instance FromJSON PostgresConf where     parseJSON = withObject "PostgresConf" $ \o -> do
persistent-postgresql.cabal view
@@ -1,5 +1,5 @@ name:            persistent-postgresql-version:         2.1.2.2+version:         2.1.3 license:         MIT license-file:    LICENSE author:          Felipe Lessa, Michael Snoyman <michael@snoyman.com>@@ -15,7 +15,7 @@ extra-source-files: ChangeLog.md  library-    build-depends:   base                  >= 4        && < 5+    build-depends:   base                  >= 4.6        && < 5                    , transformers          >= 0.2.1                    , postgresql-simple     >= 0.4.0    && < 0.5                    , postgresql-libpq      >= 0.6.1    && < 0.10