packages feed

persistent-postgresql 2.13.3.0 → 2.13.4.0

raw patch · 3 files changed

+29/−6 lines, 3 filesdep +vaultdep ~persistent

Dependencies added: vault

Dependency ranges changed: persistent

Files

ChangeLog.md view
@@ -1,5 +1,12 @@ # Changelog for persistent-postgresql +## 2.13.4.0++* [#1341](https://github.com/yesodweb/persistent/pull/1341)+    * Add `SqlBackendHooks` to allow for instrumentation of queries.+* [#1327](https://github.com/yesodweb/persistent/pull/1327)+    * Update backend to support new `StatementCache` interface+ ## 2.13.3.0  * [#1349](https://github.com/yesodweb/persistent/pull/1349)
Database/Persist/Postgresql.hs view
@@ -47,6 +47,7 @@     , upsertManyWhere     , openSimpleConn     , openSimpleConnWithVersion+    , getSimpleConn     , tableName     , fieldName     , mockMigration@@ -119,6 +120,9 @@ import Database.Persist.Sql import qualified Database.Persist.Sql.Util as Util import Database.Persist.SqlBackend+import Database.Persist.SqlBackend.StatementCache (StatementCache, mkSimpleStatementCache, mkStatementCache)+import qualified Data.Vault.Strict as Vault+import System.IO.Unsafe (unsafePerformIO)  -- | A @libpq@ connection string.  A simple example of connection -- string would be @\"host=localhost port=5432 user=test@@ -291,7 +295,7 @@     conn <- PG.connectPostgreSQL cstr     modConn conn     ver <- getVer conn-    smap <- newIORef $ Map.empty+    smap <- newIORef mempty     return $ constructor (createBackend logFunc ver smap) conn  -- | Gets the PostgreSQL server version@@ -360,10 +364,21 @@ -- @since 2.9.1 openSimpleConnWithVersion :: (PG.Connection -> IO (Maybe Double)) -> LogFunc -> PG.Connection -> IO SqlBackend openSimpleConnWithVersion getVerDouble logFunc conn = do-    smap <- newIORef $ Map.empty+    smap <- newIORef mempty     serverVersion <- oldGetVersionToNew getVerDouble conn     return $ createBackend logFunc serverVersion smap conn +underlyingConnectionKey :: Vault.Key PG.Connection+underlyingConnectionKey = unsafePerformIO Vault.newKey+{-# NOINLINE underlyingConnectionKey #-}++-- | Access underlying connection, returning 'Nothing' if the 'SqlBackend'+-- provided isn't backed by postgresql-simple.+--+-- @since 2.13.0+getSimpleConn :: (BackendCompatible SqlBackend backend) => backend -> Maybe PG.Connection+getSimpleConn = Vault.lookup underlyingConnectionKey <$> getConnVault+ -- | Create the backend given a logging function, server version, mutable statement cell, -- and connection. createBackend :: LogFunc -> NonEmpty Word@@ -373,7 +388,7 @@     maybe id setConnUpsertSql (upsertFunction upsertSql' serverVersion) $     setConnInsertManySql insertManySql' $     maybe id setConnRepsertManySql (upsertFunction repsertManySql serverVersion) $-    mkSqlBackend MkSqlBackendArgs+    modifyConnVault (Vault.insert underlyingConnectionKey conn) $ mkSqlBackend MkSqlBackendArgs         { connPrepare    = prepare' conn         , connStmtMap    = smap         , connInsertSql  = insertSql'@@ -1508,7 +1523,7 @@ -- with the difference that an actual database is not needed. mockMigration :: Migration -> IO () mockMigration mig = do-    smap <- newIORef $ Map.empty+    smap <- newIORef mempty     let sqlbackend =             mkSqlBackend MkSqlBackendArgs                 { connPrepare = \_ -> do
persistent-postgresql.cabal view
@@ -1,5 +1,5 @@ name:            persistent-postgresql-version:         2.13.3.0+version:         2.13.4.0 license:         MIT license-file:    LICENSE author:          Felipe Lessa, Michael Snoyman <michael@snoyman.com>@@ -16,7 +16,7 @@  library     build-depends:   base                  >= 4.9      && < 5-                   , persistent            >= 2.13     && < 3+                   , persistent            >= 2.13.3   && < 3                    , aeson                 >= 1.0                    , attoparsec                    , blaze-builder@@ -34,6 +34,7 @@                    , time                  >= 1.6                    , transformers          >= 0.5                    , unliftio-core+                   , vault     exposed-modules: Database.Persist.Postgresql                    , Database.Persist.Postgresql.Internal                    , Database.Persist.Postgresql.JSON