hasql/library/Hasql/Commands.hs

28 lines
673 B
Haskell
Raw Normal View History

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