{-# LANGUAGE OverloadedStrings #-}
module Hasql.Private.Statements where
import ByteString.TreeBuilder (toByteString)
import Hasql.Statement
import Hasql.Encoders
import Hasql.Decoders
import Hasql.Private.Types
startTransaction :: IsolationLevel -> Mode -> Deferrable -> Bool -> Statement () ()
startTransaction :: IsolationLevel -> Mode -> Deferrable -> Bool -> Statement () ()
startTransaction IsolationLevel
isolation Mode
mode Deferrable
deferrable =
ByteString -> Params () -> Result () -> Bool -> Statement () ()
forall a b.
ByteString -> Params a -> Result b -> Bool -> Statement a b
Statement ByteString
stmt Params ()
noParams Result ()
noResult
where
stmt :: ByteString
stmt = Builder -> ByteString
toByteString (Builder -> ByteString) -> Builder -> ByteString
forall a b. (a -> b) -> a -> b
$
Builder
"START TRANSACTION ISOLATION LEVEL " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<>
IsolationLevel -> Builder
isolationLevelToSQL IsolationLevel
isolation Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
" " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<>
Mode -> Builder
modeToSQL Mode
mode Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
" " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<>
Deferrable -> Builder
deferrableToSQL Deferrable
deferrable
commitTransaction :: Bool -> Statement () ()
commitTransaction :: Bool -> Statement () ()
commitTransaction = ByteString -> Params () -> Result () -> Bool -> Statement () ()
forall a b.
ByteString -> Params a -> Result b -> Bool -> Statement a b
Statement ByteString
"COMMIT" Params ()
noParams Result ()
noResult
rollbackTransaction :: Bool -> Statement () ()
rollbackTransaction :: Bool -> Statement () ()
rollbackTransaction = ByteString -> Params () -> Result () -> Bool -> Statement () ()
forall a b.
ByteString -> Params a -> Result b -> Bool -> Statement a b
Statement ByteString
"ROLLBACK" Params ()
noParams Result ()
noResult