2015-11-08 21:09:42 +03:00
|
|
|
module Hasql.Commands
|
|
|
|
(
|
|
|
|
Commands,
|
|
|
|
asBytes,
|
2015-12-05 09:09:31 +03:00
|
|
|
setEncodersToUTF8,
|
2015-11-08 21:09:42 +03:00
|
|
|
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 =
|
2015-11-08 21:18:59 +03:00
|
|
|
Commands (DList BB.Builder)
|
|
|
|
deriving (Monoid)
|
2015-11-08 21:09:42 +03:00
|
|
|
|
2016-02-23 09:39:57 +03:00
|
|
|
instance Semigroup Commands
|
|
|
|
|
2015-11-08 21:09:42 +03:00
|
|
|
asBytes :: Commands -> ByteString
|
|
|
|
asBytes (Commands list) =
|
|
|
|
BL.toStrict $ BB.toLazyByteString $ foldMap (<> BB.char7 ';') $ list
|
|
|
|
|
2015-12-05 09:09:31 +03:00
|
|
|
setEncodersToUTF8 :: Commands
|
|
|
|
setEncodersToUTF8 =
|
2015-11-08 21:09:42 +03:00
|
|
|
Commands (pure "SET client_encoding = 'UTF8'")
|
|
|
|
|
|
|
|
setMinClientMessagesToWarning :: Commands
|
|
|
|
setMinClientMessagesToWarning =
|
|
|
|
Commands (pure "SET client_min_messages TO WARNING")
|