graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellSafe-Inferred
LanguageHaskell2010

Database.MSSQL.Transaction

Synopsis

Documentation

newtype TxET e m a Source #

The transaction command to run, parameterised over: e - the exception type (usually MSSQLTxError) m - some Monad, (usually some MonadIO) a - the successful result type

Constructors

TxET 

Fields

Instances

Instances details
MFunctor (TxET e :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Database.MSSQL.Transaction

Methods

hoist :: forall m n (b :: k). Monad m => (forall a. m a -> n a) -> TxET e m b -> TxET e n b Source #

Monad m => MonadError e (TxET e m) Source # 
Instance details

Defined in Database.MSSQL.Transaction

Methods

throwError :: e -> TxET e m a #

catchError :: TxET e m a -> (e -> TxET e m a) -> TxET e m a #

Monad m => MonadReader Connection (TxET e m) Source # 
Instance details

Defined in Database.MSSQL.Transaction

Methods

ask :: TxET e m Connection #

local :: (Connection -> Connection) -> TxET e m a -> TxET e m a #

reader :: (Connection -> a) -> TxET e m a #

MonadTrans (TxET e) Source # 
Instance details

Defined in Database.MSSQL.Transaction

Methods

lift :: Monad m => m a -> TxET e m a #

MonadFix m => MonadFix (TxET e m) Source # 
Instance details

Defined in Database.MSSQL.Transaction

Methods

mfix :: (a -> TxET e m a) -> TxET e m a #

MonadIO m => MonadIO (TxET e m) Source # 
Instance details

Defined in Database.MSSQL.Transaction

Methods

liftIO :: IO a -> TxET e m a #

Monad m => Applicative (TxET e m) Source # 
Instance details

Defined in Database.MSSQL.Transaction

Methods

pure :: a -> TxET e m a #

(<*>) :: TxET e m (a -> b) -> TxET e m a -> TxET e m b #

liftA2 :: (a -> b -> c) -> TxET e m a -> TxET e m b -> TxET e m c #

(*>) :: TxET e m a -> TxET e m b -> TxET e m b #

(<*) :: TxET e m a -> TxET e m b -> TxET e m a #

Functor m => Functor (TxET e m) Source # 
Instance details

Defined in Database.MSSQL.Transaction

Methods

fmap :: (a -> b) -> TxET e m a -> TxET e m b #

(<$) :: a -> TxET e m b -> TxET e m a #

Monad m => Monad (TxET e m) Source # 
Instance details

Defined in Database.MSSQL.Transaction

Methods

(>>=) :: TxET e m a -> (a -> TxET e m b) -> TxET e m b #

(>>) :: TxET e m a -> TxET e m b -> TxET e m b #

return :: a -> TxET e m a #

MonadIO m => MonadMSSQLTx (TxET QErr m) Source # 
Instance details

Defined in Hasura.Backends.MSSQL.Connection

Methods

liftMSSQLTx :: TxE QErr a -> TxET QErr m a Source #

CacheRM m => CacheRM (TxET e m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

data MSSQLTxError Source #

Error type generally used in TxET.

Instances

Instances details
Show MSSQLTxError Source # 
Instance details

Defined in Database.MSSQL.Transaction

Eq MSSQLTxError Source # 
Instance details

Defined in Database.MSSQL.Transaction

type TxE e a = TxET e IO a Source #

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.

buildGenericQueryTxE Source #

Arguments

:: MonadIO m 
=> (MSSQLTxError -> e)

map MSSQLTxError to some other type

-> query

query to run

-> (query -> Query)

how to map a query to a Query

-> (Connection -> query -> IO a)

run the query on a provided Connection

-> 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 #

Instances

Instances details
FromJSON TxIsolation Source # 
Instance details

Defined in Database.MSSQL.Transaction

ToJSON TxIsolation Source # 
Instance details

Defined in Database.MSSQL.Transaction

HasCodec TxIsolation Source # 
Instance details

Defined in Database.MSSQL.Transaction

Generic TxIsolation Source # 
Instance details

Defined in Database.MSSQL.Transaction

Associated Types

type Rep TxIsolation :: Type -> Type #

Show TxIsolation Source # 
Instance details

Defined in Database.MSSQL.Transaction

NFData TxIsolation Source # 
Instance details

Defined in Database.MSSQL.Transaction

Methods

rnf :: TxIsolation -> () #

Eq TxIsolation Source # 
Instance details

Defined in Database.MSSQL.Transaction

Hashable TxIsolation Source # 
Instance details

Defined in Database.MSSQL.Transaction

type Rep TxIsolation Source # 
Instance details

Defined in Database.MSSQL.Transaction

type Rep TxIsolation = D1 ('MetaData "TxIsolation" "Database.MSSQL.Transaction" "graphql-engine-1.0.0-inplace" 'False) ((C1 ('MetaCons "ReadUncommitted" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ReadCommitted" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "RepeatableRead" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Snapshot" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Serializable" 'PrefixI 'False) (U1 :: Type -> Type))))