2016-08-06 12:22:11 +03:00
|
|
|
module Hasql.Private.Commands
|
2015-11-08 21:09:42 +03:00
|
|
|
(
|
|
|
|
Commands,
|
|
|
|
asBytes,
|
2015-12-05 09:09:31 +03:00
|
|
|
setEncodersToUTF8,
|
2015-11-08 21:09:42 +03:00
|
|
|
setMinClientMessagesToWarning,
|
|
|
|
)
|
|
|
|
where
|
|
|
|
|
2016-08-06 12:22:11 +03:00
|
|
|
import Hasql.Private.Prelude
|
2015-11-08 21:09:42 +03:00
|
|
|
import qualified Data.ByteString as B
|
2021-11-01 23:07:33 +03:00
|
|
|
import qualified Data.ByteString.Builder as BB
|
2015-11-08 21:09:42 +03:00
|
|
|
import qualified Data.ByteString.Lazy as BL
|
|
|
|
|
|
|
|
|
|
|
|
newtype Commands =
|
2015-11-08 21:18:59 +03:00
|
|
|
Commands (DList BB.Builder)
|
2018-06-05 11:19:50 +03:00
|
|
|
deriving (Semigroup, Monoid)
|
2016-02-23 09:39:57 +03:00
|
|
|
|
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")
|