Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- newtype TxET e m a = TxET {
- txHandler :: ReaderT Connection (ExceptT e m) a
- data MSSQLTxError
- type TxE e a = TxET e IO a
- type TxT m a = TxET MSSQLTxError m a
- runTx :: (MonadIO m, MonadBaseControl IO m) => TxIsolation -> TxT m a -> MSSQLPool -> ExceptT MSSQLTxError m a
- runTxE :: (MonadIO m, MonadBaseControl IO m) => (MSSQLTxError -> e) -> TxIsolation -> TxET e m a -> MSSQLPool -> ExceptT e m a
- unitQuery :: MonadIO m => Query -> TxT m ()
- unitQueryE :: MonadIO m => (MSSQLTxError -> e) -> Query -> TxET e m ()
- singleRowQuery :: forall a m. (MonadIO m, FromRow a) => Query -> TxT m a
- singleRowQueryE :: forall m a e. (MonadIO m, FromRow a) => (MSSQLTxError -> e) -> Query -> TxET e m a
- forJsonQueryE :: forall m e. MonadIO m => (MSSQLTxError -> e) -> Query -> TxET e m Text
- multiRowQuery :: forall a m. (MonadIO m, FromRow a) => Query -> TxT m [a]
- multiRowQueryE :: forall m a e. (MonadIO m, FromRow a) => (MSSQLTxError -> e) -> Query -> TxET e m [a]
- buildGenericQueryTxE :: MonadIO m => (MSSQLTxError -> e) -> query -> (query -> Query) -> (Connection -> query -> IO a) -> TxET e m a
- withTxET :: Monad m => (e1 -> e2) -> TxET e1 m a -> TxET e2 m a
- data TxIsolation
Documentation
The transaction command to run, parameterised over:
e - the exception type (usually MSSQLTxError
)
m - some Monad, (usually some MonadIO
)
a - the successful result type
TxET | |
|
Instances
data MSSQLTxError Source #
Error type generally used in TxET
.
Instances
Show MSSQLTxError Source # | |
Defined in Database.MSSQL.Transaction showsPrec :: Int -> MSSQLTxError -> ShowS # show :: MSSQLTxError -> String # showList :: [MSSQLTxError] -> ShowS # | |
Eq MSSQLTxError Source # | |
Defined in Database.MSSQL.Transaction (==) :: MSSQLTxError -> MSSQLTxError -> Bool # (/=) :: MSSQLTxError -> MSSQLTxError -> Bool # |
type TxT m a = TxET MSSQLTxError m a Source #
The transaction command to run, returning an MSSQLTxError or the result.
runTx :: (MonadIO m, MonadBaseControl IO m) => TxIsolation -> TxT m a -> MSSQLPool -> ExceptT MSSQLTxError m a Source #
Run a command on the given connection wrapped in a transaction.
See runTxE
if you need to map the error type as well.
runTxE :: (MonadIO m, MonadBaseControl IO m) => (MSSQLTxError -> e) -> TxIsolation -> TxET e m a -> MSSQLPool -> ExceptT e m a Source #
Run a command on the given connection wrapped in a transaction.
unitQuery :: MonadIO m => Query -> TxT m () Source #
Useful for building transactions which return no data.
insertId :: TxT m () insertId = unitQuery "INSERT INTO some_table VALUES (1, "hello")"
See unitQueryE
if you need to map the error type as well.
unitQueryE :: MonadIO m => (MSSQLTxError -> e) -> Query -> TxET e m () Source #
Useful for building transactions which return no data.
singleRowQuery :: forall a m. (MonadIO m, FromRow a) => Query -> TxT m a Source #
Useful for building query transactions which return a single one row.
returnOne :: TxT m Int returnOne = singleRowQuery "SELECT 1"
See singleRowQueryE
if you need to map the error type as well.
singleRowQueryE :: forall m a e. (MonadIO m, FromRow a) => (MSSQLTxError -> e) -> Query -> TxET e m a Source #
Useful for building query transactions which return a single one row.
forJsonQueryE :: forall m e. MonadIO m => (MSSQLTxError -> e) -> Query -> TxET e m Text Source #
MSSQL splits up results that have a SELECT .. FOR JSON
at the top-level
into multiple rows with a single column, see
https://docs.microsoft.com/en-us/sql/relational-databases/json/format-query-results-as-json-with-for-json-sql-server?view=sql-server-ver15#output-of-the-for-json-clause
This function simply concatenates each single-column row into one long Text
string.
multiRowQuery :: forall a m. (MonadIO m, FromRow a) => Query -> TxT m [a] Source #
Useful for building query transactions which return multiple rows.
selectIds :: TxT m [Int] selectIds = multiRowQuery "SELECT id FROM author"
See multiRowQueryE
if you need to map the error type as well.
multiRowQueryE :: forall m a e. (MonadIO m, FromRow a) => (MSSQLTxError -> e) -> Query -> TxET e m [a] Source #
Useful for building query transactions which return multiple rows.
:: MonadIO m | |
=> (MSSQLTxError -> e) | map |
-> query | query to run |
-> (query -> Query) | how to map a query to a |
-> (Connection -> query -> IO a) | run the query on a provided |
-> TxET e m a |
Build a generic transaction out of an IO action.
withTxET :: Monad m => (e1 -> e2) -> TxET e1 m a -> TxET e2 m a Source #
Map the error type for a TxET
.
data TxIsolation Source #