hasql/library/Hasql/Private/Commands.hs

28 lines
689 B
Haskell
Raw Normal View History

module Hasql.Private.Commands
2022-06-20 13:54:54 +03:00
( Commands,
asBytes,
setEncodersToUTF8,
setMinClientMessagesToWarning,
)
2015-11-08 21:09:42 +03:00
where
import qualified Data.ByteString.Builder as BB
2015-11-08 21:09:42 +03:00
import qualified Data.ByteString.Lazy as BL
2022-06-20 13:54:54 +03:00
import Hasql.Private.Prelude
2015-11-08 21:09:42 +03:00
2022-06-20 13:54:54 +03:00
newtype Commands
= 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")