{-# LANGUAGE RankNTypes #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Database.PostgreSQL.Tx.Query
( PgQueryEnv
, PgQueryM
, Logger
, module Database.PostgreSQL.Tx.Query
, module Database.PostgreSQL.Tx.Query.Internal.Reexport
) where
import Control.Exception (Exception)
import Data.Int (Int64)
import Database.PostgreSQL.Tx (TxM)
import Database.PostgreSQL.Tx.Query.Internal
import Database.PostgreSQL.Tx.Query.Internal.Reexport
import GHC.Stack (HasCallStack)
import qualified Database.PostgreSQL.Query as Query
import qualified Database.PostgreSQL.Simple.Transaction as Simple
import qualified Database.PostgreSQL.Tx.Simple as Tx.Simple
pgWithTransaction
:: (PgQueryEnv r, HasCallStack)
=> r -> (HasCallStack => TxM r a) -> IO a
pgWithTransaction :: r -> (HasCallStack => TxM r a) -> IO a
pgWithTransaction = (HasCallStack => UnsafePgQueryIO r a -> UnsafePgQueryIO r a)
-> r -> TxM r a -> IO a
forall r a.
(PgQueryEnv r, HasCallStack) =>
(HasCallStack => UnsafePgQueryIO r a -> UnsafePgQueryIO r a)
-> r -> TxM r a -> IO a
unsafeRunPgQueryTransaction HasCallStack => UnsafePgQueryIO r a -> UnsafePgQueryIO r a
forall (m :: * -> *) a.
(HasPostgres m, MonadBaseControl IO m, TransactionSafe m) =>
m a -> m a
Query.pgWithTransaction
pgWithTransactionMode
:: (PgQueryEnv r, HasCallStack)
=> Simple.TransactionMode -> r -> (HasCallStack => TxM r a) -> IO a
pgWithTransactionMode :: TransactionMode -> r -> (HasCallStack => TxM r a) -> IO a
pgWithTransactionMode m :: TransactionMode
m = (HasCallStack => UnsafePgQueryIO r a -> UnsafePgQueryIO r a)
-> r -> TxM r a -> IO a
forall r a.
(PgQueryEnv r, HasCallStack) =>
(HasCallStack => UnsafePgQueryIO r a -> UnsafePgQueryIO r a)
-> r -> TxM r a -> IO a
unsafeRunPgQueryTransaction (TransactionMode -> UnsafePgQueryIO r a -> UnsafePgQueryIO r a
forall (m :: * -> *) a.
(HasPostgres m, MonadBaseControl IO m, TransactionSafe m) =>
TransactionMode -> m a -> m a
Query.pgWithTransactionMode TransactionMode
m)
pgWithTransactionSerializable
:: (PgQueryEnv r, HasCallStack)
=> r -> (HasCallStack => TxM r a) -> IO a
pgWithTransactionSerializable :: r -> (HasCallStack => TxM r a) -> IO a
pgWithTransactionSerializable = r -> (HasCallStack => TxM r a) -> IO a
forall r a.
(PgSimpleEnv r, HasCallStack) =>
r -> (HasCallStack => TxM r a) -> IO a
Tx.Simple.withTransactionSerializable
pgWithTransactionModeRetry
:: (PgQueryEnv r, Exception e, HasCallStack)
=> Simple.TransactionMode -> (e -> Bool) -> r -> (HasCallStack => TxM r a) -> IO a
pgWithTransactionModeRetry :: TransactionMode
-> (e -> Bool) -> r -> (HasCallStack => TxM r a) -> IO a
pgWithTransactionModeRetry = TransactionMode
-> (e -> Bool) -> r -> (HasCallStack => TxM r a) -> IO a
forall e r a.
(Exception e, PgSimpleEnv r, HasCallStack) =>
TransactionMode
-> (e -> Bool) -> r -> (HasCallStack => TxM r a) -> IO a
Tx.Simple.withTransactionModeRetry
pgWithSavepoint :: (HasCallStack => PgQueryM a) -> PgQueryM a
pgWithSavepoint :: (HasCallStack => PgQueryM a) -> PgQueryM a
pgWithSavepoint x :: HasCallStack => PgQueryM a
x =
UnsafePgQueryIO r a -> TxM r a
forall r a. HasCallStack => UnsafePgQueryIO r a -> TxM r a
unsafeFromPgQueryIO
(UnsafePgQueryIO r a -> TxM r a) -> UnsafePgQueryIO r a -> TxM r a
forall a b. (a -> b) -> a -> b
$ UnsafePgQueryIO r a -> UnsafePgQueryIO r a
forall (m :: * -> *) a.
(HasPostgres m, MonadBaseControl IO m, TransactionSafe m) =>
m a -> m a
Query.pgWithSavepoint
(UnsafePgQueryIO r a -> UnsafePgQueryIO r a)
-> UnsafePgQueryIO r a -> UnsafePgQueryIO r a
forall a b. (a -> b) -> a -> b
$ TxM r a -> UnsafePgQueryIO r a
forall r a. HasCallStack => TxM r a -> UnsafePgQueryIO r a
unsafeToPgQueryIO TxM r a
HasCallStack => PgQueryM a
x
pgQuery :: (ToSqlBuilder q, FromRow r, HasCallStack) => q -> PgQueryM [r]
pgQuery :: q -> PgQueryM [r]
pgQuery = UnsafePgQueryIO r [r] -> TxM r [r]
forall r a. HasCallStack => UnsafePgQueryIO r a -> TxM r a
unsafeFromPgQueryIO (UnsafePgQueryIO r [r] -> TxM r [r])
-> (q -> UnsafePgQueryIO r [r]) -> q -> TxM r [r]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. q -> UnsafePgQueryIO r [r]
forall (m :: * -> *) q r.
(HasPostgres m, MonadLogger m, ToSqlBuilder q, FromRow r) =>
q -> m [r]
Query.pgQuery
pgQueryWithMasker :: (ToSqlBuilder q, FromRow r, HasCallStack) => LogMasker -> q -> PgQueryM [r]
pgQueryWithMasker :: LogMasker -> q -> PgQueryM [r]
pgQueryWithMasker masker :: LogMasker
masker = UnsafePgQueryIO r [r] -> TxM r [r]
forall r a. HasCallStack => UnsafePgQueryIO r a -> TxM r a
unsafeFromPgQueryIO (UnsafePgQueryIO r [r] -> TxM r [r])
-> (q -> UnsafePgQueryIO r [r]) -> q -> TxM r [r]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LogMasker -> q -> UnsafePgQueryIO r [r]
forall (m :: * -> *) q r.
(HasPostgres m, MonadLogger m, ToSqlBuilder q, FromRow r) =>
LogMasker -> q -> m [r]
Query.pgQueryWithMasker LogMasker
masker
pgExecute :: (ToSqlBuilder q, HasCallStack) => q -> PgQueryM Int64
pgExecute :: q -> PgQueryM Int64
pgExecute = UnsafePgQueryIO r Int64 -> TxM r Int64
forall r a. HasCallStack => UnsafePgQueryIO r a -> TxM r a
unsafeFromPgQueryIO (UnsafePgQueryIO r Int64 -> TxM r Int64)
-> (q -> UnsafePgQueryIO r Int64) -> q -> TxM r Int64
forall b c a. (b -> c) -> (a -> b) -> a -> c
. q -> UnsafePgQueryIO r Int64
forall (m :: * -> *) q.
(HasPostgres m, MonadLogger m, ToSqlBuilder q) =>
q -> m Int64
Query.pgExecute
pgExecuteWithMasker :: (ToSqlBuilder q, HasCallStack) => LogMasker -> q -> PgQueryM Int64
pgExecuteWithMasker :: LogMasker -> q -> PgQueryM Int64
pgExecuteWithMasker masker :: LogMasker
masker = UnsafePgQueryIO r Int64 -> TxM r Int64
forall r a. HasCallStack => UnsafePgQueryIO r a -> TxM r a
unsafeFromPgQueryIO (UnsafePgQueryIO r Int64 -> TxM r Int64)
-> (q -> UnsafePgQueryIO r Int64) -> q -> TxM r Int64
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LogMasker -> q -> UnsafePgQueryIO r Int64
forall (m :: * -> *) q.
(HasPostgres m, MonadLogger m, ToSqlBuilder q) =>
LogMasker -> q -> m Int64
Query.pgExecuteWithMasker LogMasker
masker