mirror of
https://github.com/nikita-volkov/hasql.git
synced 2024-11-30 00:55:22 +03:00
34 lines
785 B
Haskell
34 lines
785 B
Haskell
module Hasql.Commands
|
|
(
|
|
Commands,
|
|
asBytes,
|
|
setEncodersToUTF8,
|
|
setMinClientMessagesToWarning,
|
|
)
|
|
where
|
|
|
|
import Hasql.Prelude
|
|
import qualified Data.ByteString as B
|
|
import qualified Data.ByteString.Lazy.Builder as BB
|
|
import qualified Data.ByteString.Lazy.Builder.ASCII as BB
|
|
import qualified Data.ByteString.Lazy as BL
|
|
|
|
|
|
newtype Commands =
|
|
Commands (DList BB.Builder)
|
|
deriving (Monoid)
|
|
|
|
instance Semigroup Commands
|
|
|
|
asBytes :: Commands -> ByteString
|
|
asBytes (Commands list) =
|
|
BL.toStrict $ BB.toLazyByteString $ foldMap (<> BB.char7 ';') $ list
|
|
|
|
setEncodersToUTF8 :: Commands
|
|
setEncodersToUTF8 =
|
|
Commands (pure "SET client_encoding = 'UTF8'")
|
|
|
|
setMinClientMessagesToWarning :: Commands
|
|
setMinClientMessagesToWarning =
|
|
Commands (pure "SET client_min_messages TO WARNING")
|