packages feed

postgresql-query 3.6.0 → 3.7.0

raw patch · 5 files changed

+51/−33 lines, 5 files

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # CHANGELOG +## 3.7.0+### Changed+* Use 'HasCallStack' and logging with stack (ilyakooo0)+ ## 3.6.0 ### Changed * Compatibility with ghc-8.6.5
postgresql-query.cabal view
@@ -1,5 +1,5 @@ name:                postgresql-query-version:             3.6.0+version:             3.7.0  synopsis: Sql interpolating quasiquote plus some kind of primitive ORM           using it@@ -59,6 +59,7 @@                     , MultiParamTypeClasses                     , OverloadedStrings                     , QuasiQuotes+                    , RankNTypes                     , RecordWildCards                     , ScopedTypeVariables                     , StandaloneDeriving
src/Database/PostgreSQL/Query/Functions.hs view
@@ -45,58 +45,63 @@ -}  pgQuery-  :: (HasPostgres m, MonadLogger m, ToSqlBuilder q, FromRow r)+  :: (MonadPostgres m, ToSqlBuilder q, FromRow r, HasCallStack)   => q   -> m [r]-pgQuery = pgQueryWithMasker defaultLogMasker+pgQuery = withFrozenCallStack $ pgQueryWithMasker defaultLogMasker  -- | Execute arbitrary query and return count of affected rows pgExecute-  :: (HasPostgres m, MonadLogger m, ToSqlBuilder q)+  :: (MonadPostgres m, ToSqlBuilder q, HasCallStack)   => q   -> m Int64-pgExecute = pgExecuteWithMasker defaultLogMasker+pgExecute = withFrozenCallStack $ pgExecuteWithMasker defaultLogMasker  pgQueryWithMasker-  :: (HasPostgres m, MonadLogger m, ToSqlBuilder q, FromRow r)+  :: (MonadPostgres m, ToSqlBuilder q, FromRow r, HasCallStack)   => LogMasker   -> q   -> m [r]-pgQueryWithMasker masker q = withPGConnection $ \c -> do+pgQueryWithMasker masker q = withFrozenCallStack $ withPGConnection $ \c -> do     (queryBs, logBs) <- liftBase $ runSqlBuilder c masker $ toSqlBuilder q-    logDebugN $ T.decodeUtf8 logBs+    logDebug $ T.decodeUtf8 logBs     liftBase $ query_ c queryBs  pgExecuteWithMasker-  :: (HasPostgres m, MonadLogger m, ToSqlBuilder q)+  :: (MonadPostgres m, ToSqlBuilder q, HasCallStack)   => LogMasker   -> q   -> m Int64-pgExecuteWithMasker masker q = withPGConnection $ \c -> do+pgExecuteWithMasker masker q = withFrozenCallStack $ withPGConnection $ \c -> do     (queryBs, logBs) <- liftBase $ runSqlBuilder c masker $ toSqlBuilder q-    logDebugN $ T.decodeUtf8 logBs+    logDebug $ T.decodeUtf8 logBs     liftBase $ execute_ c queryBs  -- | Execute all queries inside one transaction. Rollback transaction on exceptions-pgWithTransaction :: (HasPostgres m, MonadBaseControl IO m, TransactionSafe m)-                  => m a-                  -> m a+pgWithTransaction+  :: (HasPostgres m, MonadBaseControl IO m, TransactionSafe m, HasCallStack)+  => (HasCallStack => m a)+  -> m a pgWithTransaction action = withPGConnection $ \con -> do     control $ \runInIO -> do         withTransaction con $ runInIO action  -- | Same as `pgWithTransaction` but executes queries inside savepoint-pgWithSavepoint :: (HasPostgres m, MonadBaseControl IO m, TransactionSafe m) => m a -> m a+pgWithSavepoint+  :: (HasPostgres m, MonadBaseControl IO m, TransactionSafe m, HasCallStack)+  => (HasCallStack => m a)+  -> m a pgWithSavepoint action = withPGConnection $ \con -> do     control $ \runInIO -> do         withSavepoint con $ runInIO action  -- | Wrapper for 'withTransactionMode': Execute an action inside a SQL -- transaction with a given transaction mode.-pgWithTransactionMode :: (HasPostgres m, MonadBaseControl IO m, TransactionSafe m)-                       => TransactionMode-                       -> m a-                       -> m a+pgWithTransactionMode+  :: (HasPostgres m, MonadBaseControl IO m, TransactionSafe m, HasCallStack)+  => TransactionMode+  -> (HasCallStack => m a)+  -> m a pgWithTransactionMode tmode ma = withPGConnection $ \con -> do     control $ \runInIO -> do         withTransactionMode tmode con $ runInIO ma@@ -107,11 +112,12 @@ -- True, then the transaction will be retried. If the callback returns -- False, or an exception other than an SqlError occurs then the -- transaction will be rolled back and the exception rethrown.-pgWithTransactionModeRetry :: (HasPostgres m, MonadBaseControl IO m, TransactionSafe m)-                           => TransactionMode-                           -> (SqlError -> Bool)-                           -> m a-                           -> m a+pgWithTransactionModeRetry+  :: (HasPostgres m, MonadBaseControl IO m, TransactionSafe m, HasCallStack)+  => TransactionMode+  -> (SqlError -> Bool)+  -> (HasCallStack => m a)+  -> m a pgWithTransactionModeRetry tmode epred ma = withPGConnection $ \con -> do     control $ \runInIO -> do         withTransactionModeRetry tmode epred con $ runInIO ma@@ -126,9 +132,10 @@ -- concurrent setting, you can perform queries in sequence without -- having to worry about what might happen between one statement and -- the next.-pgWithTransactionSerializable :: (HasPostgres m, MonadBaseControl IO m, TransactionSafe m)-                              => m a-                              -> m a+pgWithTransactionSerializable+  :: (HasPostgres m, MonadBaseControl IO m, TransactionSafe m)+  => (HasCallStack => m a)+  -> m a pgWithTransactionSerializable ma = withPGConnection $ \con -> do     control $ \runInIO -> do         withTransactionSerializable con $ runInIO ma@@ -160,7 +167,7 @@  pgRepsertRow   :: ( MonadPostgres m, MonadLogger m-     , ToMarkedRow wrow, ToMarkedRow urow)+     , ToMarkedRow wrow, ToMarkedRow urow, HasCallStack)   => FN                         -- ^ Table name   -> wrow                       -- ^ where condition   -> urow                       -- ^ update row
src/Database/PostgreSQL/Query/Import.hs view
@@ -9,7 +9,7 @@ import Control.Monad as X import Control.Monad.Base as X import Control.Monad.Catch as X-import Control.Monad.Logger as X+import Control.Monad.Logger.CallStack as X import Control.Monad.Trans.Control as X import Data.List.NonEmpty as X (NonEmpty) import Data.Maybe as X@@ -18,6 +18,7 @@ import Data.Text as X (Text) import Data.Typeable as X import GHC.Generics as X (Generic)+import GHC.Stack as X  #if MIN_VERSION_base(4,8,0) import Data.Semigroup as X
src/Database/PostgreSQL/Query/Types.hs view
@@ -367,7 +367,11 @@ instance TransactionSafe (PgMonadT m)  -runPgMonadT :: Connection -> PgMonadT m a -> m a+runPgMonadT+  :: HasCallStack+  => Connection+  -> (HasCallStack => PgMonadT m a)+  -> m a runPgMonadT con (PgMonadT action) = runReaderT action con  {- | If your monad have instance of 'HasPostgres' you maybe dont need this@@ -377,8 +381,9 @@  -} -launchPG :: (HasPostgres m)-         => PgMonadT m a-         -> m a+launchPG+  :: (HasPostgres m, HasCallStack)+  => (HasCallStack => PgMonadT m a)+  -> m a launchPG act = withPGConnection $ \con -> do     runPgMonadT con act