packages feed

persistent-postgresql 2.2.2 → 2.5

raw patch · 3 files changed

+25/−22 lines, 3 filesdep +resource-pooldep ~persistent

Dependencies added: resource-pool

Dependency ranges changed: persistent

Files

ChangeLog.md view
@@ -1,3 +1,7 @@+## 2.5++* changes for read/write typeclass split+ ## 2.2.2  * Postgresql primary key is Int4, not Int8 [#519](https://github.com/yesodweb/persistent/issues/519)
Database/Persist/Postgresql.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs #-}@@ -25,6 +26,7 @@  import Database.Persist.Sql import Database.Persist.Sql.Util (dbIdColumnsEsc)+import Database.Persist.Sql.Types.Internal (mkPersistBackend) import Data.Fixed (Pico)  import qualified Database.PostgreSQL.Simple as PG@@ -73,6 +75,7 @@ import System.Environment (getEnvironment) import Data.Int (Int64) import Data.Monoid ((<>))+import Data.Pool (Pool) import Data.Time (utc, localTimeToUTC)  -- | A @libpq@ connection string.  A simple example of connection@@ -89,13 +92,13 @@ -- finishes using it.  Note that you should not use the given -- 'ConnectionPool' outside the action since it may be already -- been released.-withPostgresqlPool :: (MonadBaseControl IO m, MonadLogger m, MonadIO m)+withPostgresqlPool :: (MonadBaseControl IO m, MonadLogger m, MonadIO m, IsSqlBackend backend)                    => ConnectionString                    -- ^ Connection string to the database.                    -> Int                    -- ^ Number of connections to be kept open in                    -- the pool.-                   -> (ConnectionPool -> m a)+                   -> (Pool backend -> m a)                    -- ^ Action to be executed that uses the                    -- connection pool.                    -> m a@@ -106,13 +109,13 @@ -- responsibility to properly close the connection pool when -- unneeded.  Use 'withPostgresqlPool' for an automatic resource -- control.-createPostgresqlPool :: (MonadIO m, MonadBaseControl IO m, MonadLogger m)+createPostgresqlPool :: (MonadIO m, MonadBaseControl IO m, MonadLogger m, IsSqlBackend backend)                      => ConnectionString                      -- ^ Connection string to the database.                      -> Int                      -- ^ Number of connections to be kept open                      -- in the pool.-                     -> m ConnectionPool+                     -> m (Pool backend) createPostgresqlPool = createPostgresqlPoolModified (const $ return ())  -- | Same as 'createPostgresqlPool', but additionally takes a callback function@@ -124,21 +127,22 @@ -- -- Since 2.1.3 createPostgresqlPoolModified-    :: (MonadIO m, MonadBaseControl IO m, MonadLogger m)+    :: (MonadIO m, MonadBaseControl IO m, MonadLogger m, IsSqlBackend backend)     => (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+    -> m (Pool backend) 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 :: (MonadIO m, MonadBaseControl IO m, MonadLogger m, IsSqlBackend backend)+                   => ConnectionString -> (backend -> m a) -> m a withPostgresqlConn = withSqlConn . open' (const $ return ()) -open' :: (PG.Connection -> IO ())-      -> ConnectionString -> LogFunc -> IO SqlBackend+open'+    :: (IsSqlBackend backend)+    => (PG.Connection -> IO ()) -> ConnectionString -> LogFunc -> IO backend open' modConn cstr logFunc = do     conn <- PG.connectPostgreSQL cstr     modConn conn@@ -146,10 +150,10 @@   -- | Generate a 'Connection' from a 'PG.Connection'-openSimpleConn :: LogFunc -> PG.Connection -> IO SqlBackend+openSimpleConn :: (IsSqlBackend backend) => LogFunc -> PG.Connection -> IO backend openSimpleConn logFunc conn = do     smap <- newIORef $ Map.empty-    return SqlBackend+    return . mkPersistBackend $ SqlBackend         { connPrepare    = prepare' conn         , connStmtMap    = smap         , connInsertSql  = insertSql'@@ -899,18 +903,12 @@  -- | get the SQL string for the table that a PeristEntity represents -- Useful for raw SQL queries-tableName :: forall record.-          ( PersistEntity record-          , PersistEntityBackend record ~ SqlBackend-          ) => record -> Text+tableName :: (PersistEntity record) => record -> Text tableName = escape . tableDBName  -- | get the SQL string for the field that an EntityField represents -- Useful for raw SQL queries-fieldName :: forall record typ.-          ( PersistEntity record-          , PersistEntityBackend record ~ SqlBackend-          ) => EntityField record typ -> Text+fieldName :: (PersistEntity record) => EntityField record typ -> Text fieldName = escape . fieldDBName  escape :: DBName -> Text
persistent-postgresql.cabal view
@@ -1,5 +1,5 @@ name:            persistent-postgresql-version:         2.2.2+version:         2.5 license:         MIT license-file:    LICENSE author:          Felipe Lessa, Michael Snoyman <michael@snoyman.com>@@ -19,7 +19,7 @@                    , transformers          >= 0.2.1                    , postgresql-simple     >= 0.4.0    && < 0.6                    , postgresql-libpq      >= 0.6.1    && < 0.10-                   , persistent            >= 2.2      && < 3+                   , persistent            >= 2.5      && < 3                    , containers            >= 0.2                    , bytestring            >= 0.9                    , text                  >= 0.7@@ -30,6 +30,7 @@                    , conduit               >= 0.5.3                    , resourcet             >= 1.1                    , monad-logger          >= 0.3.4+                   , resource-pool     exposed-modules: Database.Persist.Postgresql     ghc-options:     -Wall