git.iko.soy/typeable/postgresql-simple
on master help sign in
Move to bytestring-builder
commitcd784ea77b6ba1ccd5b5212ab2d8e2c85720653f authorLeon P Smith <leon@melding-monads.com> dateSat 4 Apr 2015, 03:44 (12 years ago) parent99e3f0d
9 files changed+100−93
postgresql-simple.cabal+1−2 src/Database/PostgreSQL/Simple.hs+11−13 src/Database/PostgreSQL/Simple/Compat.hs+8 src/Database/PostgreSQL/Simple/HStore/Implementation.hs+10−11 src/Database/PostgreSQL/Simple/Internal.hs+4−4 src/Database/PostgreSQL/Simple/Time/Implementation.hs+19−21 src/Database/PostgreSQL/Simple/ToField.hs+43−38 src/Database/PostgreSQL/Simple/ToField.hs-boot+1−1 src/Database/PostgreSQL/Simple/Types.hs+3−3
postgresql-simple.cabal+1−2
@@ -54,9 +54,8 @@ Library
5454 aeson >= 0.6,
5555 attoparsec >= 0.10.3,
5656 base < 5,
57− blaze-builder,
58− blaze-textual,
5957 bytestring >= 0.9,
58+ bytestring-builder,
6059 case-insensitive,
6160 containers,
6261 hashable,
src/Database/PostgreSQL/Simple.hs+11−13
@@ -110,10 +110,8 @@ module Database.PostgreSQL.Simple
110110 , formatQuery
111111 ) where
112112
113−import Blaze.ByteString.Builder
114− ( Builder, fromByteString, toByteString )
115−import Blaze.ByteString.Builder.Char8 (fromChar)
116−import Blaze.Text ( integral )
113+import Data.ByteString.Builder
114+ ( Builder, byteString, char8, intDec )
117115import Control.Applicative ((<$>))
118116import Control.Exception as E
119117import Control.Monad (foldM)
@@ -121,7 +119,7 @@ import Data.ByteString (ByteString)
121119import Data.Int (Int64)
122120import Data.List (intersperse)
123121import Data.Monoid (mconcat)
124−import Database.PostgreSQL.Simple.Compat ( (<>) )
122+import Database.PostgreSQL.Simple.Compat ( (<>), toByteString )
125123import Database.PostgreSQL.Simple.FromField (ResultError(..))
126124import Database.PostgreSQL.Simple.FromRow (FromRow(..))
127125import Database.PostgreSQL.Simple.Ok
@@ -173,9 +171,9 @@ formatMany conn q@(Query template) qs = do
173171 case parseTemplate template of
174172 Just (before, qbits, after) -> do
175173 bs <- mapM (buildQuery conn q qbits . toRow) qs
176− return . toByteString . mconcat $ fromByteString before :
177− intersperse (fromChar ',') bs ++
178− [fromByteString after]
174+ return . toByteString . mconcat $ byteString before :
175+ intersperse (char8 ',') bs ++
176+ [byteString after]
179177 Nothing -> fmtError "syntax error in multi-row template" q []
180178
181179-- Split the input string into three pieces, @before@, @qbits@, and @after@,
@@ -280,7 +278,7 @@ buildQuery conn q template xs =
280278 zipParams (split template) <$> mapM (buildAction conn q xs) xs
281279 where split s =
282280 let (h,t) = B.break (=='?') s
283− in fromByteString h
281+ in byteString h
284282 : if B.null t
285283 then []
286284 else split (B.tail t)
@@ -519,10 +517,10 @@ doFold FoldOptions{..} conn _template q a0 f = do
519517 [ "DECLARE ", name, " NO SCROLL CURSOR FOR ", q ]
520518 return name
521519 fetch (Query name) = query_ conn $
522− Query (toByteString (fromByteString "FETCH FORWARD "
523− <> integral chunkSize
524− <> fromByteString " FROM "
525− <> fromByteString name
520+ Query (toByteString (byteString "FETCH FORWARD "
521+ <> intDec chunkSize
522+ <> byteString " FROM "
523+ <> byteString name
526524 ))
527525 close name =
528526 (execute_ conn ("CLOSE " <> name) >> return ()) `E.catch` \ex ->
src/Database/PostgreSQL/Simple/Compat.hs+8
@@ -5,10 +5,15 @@ module Database.PostgreSQL.Simple.Compat
55 ( mask
66 , (<>)
77 , unsafeDupablePerformIO
8+ , toByteString
89 ) where
910
1011import qualified Control.Exception as E
1112import Data.Monoid
13+import Data.ByteString (ByteString)
14+import Data.ByteString.Lazy (toStrict)
15+import Data.ByteString.Builder (Builder, toLazyByteString)
16+
1217
1318#if __GLASGOW_HASKELL__ >= 702
1419import System.IO.Unsafe (unsafeDupablePerformIO)
@@ -43,3 +48,6 @@ infixr 6 <>
4348(<>) = mappend
4449{-# INLINE (<>) #-}
4550#endif
51+
52+toByteString :: Builder -> ByteString
53+toByteString x = toStrict (toLazyByteString x)
src/Database/PostgreSQL/Simple/HStore/Implementation.hs+10−11
@@ -15,12 +15,11 @@
1515module Database.PostgreSQL.Simple.HStore.Implementation where
1616
1717import Control.Applicative
18−import Blaze.ByteString.Builder as Blaze
19− ( Builder, toLazyByteString, copyByteString )
20−import Blaze.ByteString.Builder.Char8 (fromChar)
2118import qualified Data.Attoparsec.ByteString as P
2219import qualified Data.Attoparsec.ByteString.Char8 as P (isSpace_w8)
2320import qualified Data.ByteString as BS
21+import Data.ByteString.Builder (Builder, byteString, char8)
22+import qualified Data.ByteString.Builder as BU
2423import Data.ByteString.Internal (c2w, w2c)
2524import qualified Data.ByteString.Lazy as BL
2625#if !MIN_VERSION_bytestring(0,10,0)
@@ -58,7 +57,7 @@ toBuilder x = case x of
5857toLazyByteString :: HStoreBuilder -> BL.ByteString
5958toLazyByteString x = case x of
6059 Empty -> BL.empty
61− Comma x -> Blaze.toLazyByteString x
60+ Comma x -> BU.toLazyByteString x
6261
6362instance Monoid HStoreBuilder where
6463 mempty = Empty
@@ -66,7 +65,7 @@ instance Monoid HStoreBuilder where
6665 mappend (Comma a) x
6766 = Comma (a `mappend` case x of
6867 Empty -> mempty
69− Comma b -> fromChar ',' `mappend` b)
68+ Comma b -> char8 ',' `mappend` b)
7069
7170class ToHStoreText a where
7271 toHStoreText :: a -> HStoreText
@@ -95,24 +94,24 @@ escapeAppend :: BS.ByteString -> Builder -> Builder
9594escapeAppend = loop
9695 where
9796 loop (BS.break quoteNeeded -> (a,b)) rest
98− = copyByteString a `mappend`
97+ = byteString a `mappend`
9998 case BS.uncons b of
10099 Nothing -> rest
101100 Just (c,d) -> quoteChar c `mappend` loop d rest
102101
103102 quoteNeeded c = c == c2w '\"' || c == c2w '\\'
104103 quoteChar c
105− | c == c2w '\"' = copyByteString "\\\""
106− | otherwise = copyByteString "\\\\"
104+ | c == c2w '\"' = byteString "\\\""
105+ | otherwise = byteString "\\\\"
107106
108107hstore :: (ToHStoreText a, ToHStoreText b) => a -> b -> HStoreBuilder
109108hstore (toHStoreText -> (HStoreText key)) (toHStoreText -> (HStoreText val)) =
110− Comma (fromChar '"' `mappend` key `mappend` copyByteString "\"=>\""
111− `mappend` val `mappend` fromChar '"')
109+ Comma (char8 '"' `mappend` key `mappend` byteString "\"=>\""
110+ `mappend` val `mappend` char8 '"')
112111
113112instance ToField HStoreBuilder where
114113 toField Empty = toField (BS.empty)
115− toField (Comma x) = toField (Blaze.toLazyByteString x)
114+ toField (Comma x) = toField (BU.toLazyByteString x)
116115
117116newtype HStoreList = HStoreList {fromHStoreList :: [(Text,Text)]} deriving (Typeable, Show)
118117
src/Database/PostgreSQL/Simple/Internal.hs+4−4
@@ -20,8 +20,6 @@
2020
2121module Database.PostgreSQL.Simple.Internal where
2222
23−import Blaze.ByteString.Builder
24− ( Builder, fromByteString, toByteString )
2523import Control.Applicative
2624import Control.Exception
2725import Control.Concurrent.MVar
@@ -29,6 +27,7 @@ import Control.Monad(MonadPlus(..))
2927import Data.ByteString(ByteString)
3028import qualified Data.ByteString as B
3129import qualified Data.ByteString.Char8 as B8
30+import Data.ByteString.Builder ( Builder, byteString )
3231import Data.Char (ord)
3332import Data.Int (Int64)
3433import qualified Data.IntMap as IntMap
@@ -43,6 +42,7 @@ import Data.Word
4342import Database.PostgreSQL.LibPQ(Oid(..))
4443import qualified Database.PostgreSQL.LibPQ as PQ
4544import Database.PostgreSQL.LibPQ(ExecStatus(..))
45+import Database.PostgreSQL.Simple.Compat ( toByteString )
4646import Database.PostgreSQL.Simple.Ok
4747import Database.PostgreSQL.Simple.ToField (Action(..), inQuotes)
4848import Database.PostgreSQL.Simple.Types (Query(..))
@@ -538,7 +538,7 @@ fmtErrorBs q xs msg = fmtError (T.unpack $ TE.decodeUtf8 msg) q xs
538538
539539-- | Quote bytestring or throw 'FormatError'
540540quote :: Query -> [Action] -> Either ByteString ByteString -> Builder
541−quote q xs = either (fmtErrorBs q xs) (inQuotes . fromByteString)
541+quote q xs = either (fmtErrorBs q xs) (inQuotes . byteString)
542542
543543buildAction :: Connection -- ^ Connection for string escaping
544544 -> Query -- ^ Query for message error
@@ -549,7 +549,7 @@ buildAction _ _ _ (Plain b) = pure b
549549buildAction conn q xs (Escape s) = quote q xs <$> escapeStringConn conn s
550550buildAction conn q xs (EscapeByteA s) = quote q xs <$> escapeByteaConn conn s
551551buildAction conn q xs (EscapeIdentifier s) =
552− either (fmtErrorBs q xs) fromByteString <$> escapeIdentifier conn s
552+ either (fmtErrorBs q xs) byteString <$> escapeIdentifier conn s
553553buildAction conn q xs (Many ys) =
554554 mconcat <$> mapM (buildAction conn q xs) ys
555555
src/Database/PostgreSQL/Simple/Time/Implementation.hs+19−21
@@ -13,9 +13,7 @@
1313module Database.PostgreSQL.Simple.Time.Implementation where
1414
1515import Prelude hiding (take, (++))
16−import Blaze.ByteString.Builder(Builder, fromByteString)
17−import Blaze.ByteString.Builder.Char8(fromChar)
18−import Blaze.Text.Int(integral)
16+import Data.ByteString.Builder(Builder, byteString, char8, integerDec)
1917import Control.Arrow((***))
2018import Control.Applicative
2119import Control.Monad(when)
@@ -212,25 +210,25 @@ digits msg = do
212210
213211dayToBuilder :: Day -> Builder
214212dayToBuilder (toGregorian -> (y,m,d)) = do
215− pad4 y ++ fromChar '-' ++ pad2 m ++ fromChar '-' ++ pad2 d
213+ pad4 y ++ char8 '-' ++ pad2 m ++ char8 '-' ++ pad2 d
216214
217215timeOfDayToBuilder :: TimeOfDay -> Builder
218216timeOfDayToBuilder (TimeOfDay h m s) = do
219− pad2 h ++ fromChar ':' ++ pad2 m ++ fromChar ':' ++ showSeconds s
217+ pad2 h ++ char8 ':' ++ pad2 m ++ char8 ':' ++ showSeconds s
220218
221219timeZoneToBuilder :: TimeZone -> Builder
222220timeZoneToBuilder tz
223221 | m == 0 = sign h ++ pad2 (abs h)
224− | otherwise = sign h ++ pad2 (abs h) ++ fromChar ':' ++ pad2 (abs m)
222+ | otherwise = sign h ++ pad2 (abs h) ++ char8 ':' ++ pad2 (abs m)
225223 where
226224 (h,m) = timeZoneMinutes tz `quotRem` 60
227− sign h | h >= 0 = fromChar '+'
228− | otherwise = fromChar '-'
225+ sign h | h >= 0 = char8 '+'
226+ | otherwise = char8 '-'
229227
230228utcTimeToBuilder :: UTCTime -> Builder
231229utcTimeToBuilder (UTCTime day time) =
232− dayToBuilder day ++ fromChar ' '
233− ++ timeOfDayToBuilder (timeToTimeOfDay time) ++ fromByteString "+00"
230+ dayToBuilder day ++ char8 ' '
231+ ++ timeOfDayToBuilder (timeToTimeOfDay time) ++ byteString "+00"
234232
235233zonedTimeToBuilder :: ZonedTime -> Builder
236234zonedTimeToBuilder (ZonedTime localTime tz) =
@@ -238,14 +236,14 @@ zonedTimeToBuilder (ZonedTime localTime tz) =
238236
239237localTimeToBuilder :: LocalTime -> Builder
240238localTimeToBuilder (LocalTime day tod) =
241− dayToBuilder day ++ fromChar ' ' ++ timeOfDayToBuilder tod
239+ dayToBuilder day ++ char8 ' ' ++ timeOfDayToBuilder tod
242240
243241unboundedToBuilder :: (a -> Builder) -> (Unbounded a -> Builder)
244242unboundedToBuilder finiteToBuilder unbounded
245243 = case unbounded of
246− NegInfinity -> fromByteString "-infinity"
244+ NegInfinity -> byteString "-infinity"
247245 Finite a -> finiteToBuilder a
248− PosInfinity -> fromByteString "infinity"
246+ PosInfinity -> byteString "infinity"
249247
250248utcTimestampToBuilder :: UTCTimestamp -> Builder
251249utcTimestampToBuilder = unboundedToBuilder utcTimeToBuilder
@@ -261,20 +259,20 @@ dateToBuilder = unboundedToBuilder dayToBuilder
261259
262260nominalDiffTimeToBuilder :: NominalDiffTime -> Builder
263261nominalDiffTimeToBuilder xyz
264− | yz < 500000 = sign ++ integral x
265− | otherwise = sign ++ integral x ++ fromChar '.' ++ showD6 y
262+ | yz < 500000 = sign ++ integerDec x
263+ | otherwise = sign ++ integerDec x ++ char8 '.' ++ showD6 y
266264 where
267265 -- A kludge to work around the fact that Data.Fixed isn't very fast and
268266 -- doesn't give me access to the MkFixed constructor.
269− sign = if xyz >= 0 then mempty else fromChar '-'
267+ sign = if xyz >= 0 then mempty else char8 '-'
270268 (x,yz) = ((unsafeCoerce (abs xyz) :: Integer) + 500000) `quotRem` 1000000000000
271269 (fromIntegral -> y, _z) = yz `quotRem` 1000000
272270
273271showSeconds :: Pico -> Builder
274272showSeconds xyz
275273 | yz == 0 = pad2 x
276− | z == 0 = pad2 x ++ fromChar '.' ++ showD6 y
277− | otherwise = pad2 x ++ fromChar '.' ++ pad6 y ++ showD6 z
274+ | z == 0 = pad2 x ++ char8 '.' ++ showD6 y
275+ | otherwise = pad2 x ++ char8 '.' ++ pad6 y ++ showD6 z
278276 where
279277 -- A kludge to work around the fact that Data.Fixed isn't very fast and
280278 -- doesn't give me access to the MkFixed constructor.
@@ -305,7 +303,7 @@ showD3 abc = case abc `quotRem` 100 of
305303
306304-- | p assumes its input is in the range [0..9]
307305p :: Integral n => n -> Builder
308−p n = fromChar (w2c (fromIntegral (n + 48)))
306+p n = char8 (w2c (fromIntegral (n + 48)))
309307{-# INLINE p #-}
310308
311309-- | pad2 assumes its input is in the range [0..99]
@@ -314,8 +312,8 @@ pad2 n = let (a,b) = n `quotRem` 10 in p a ++ p b
314312{-# INLINE pad2 #-}
315313
316314-- | pad4 assumes its input is positive
317−pad4 :: (Integral n, Show n) => n -> Builder
318−pad4 abcd | abcd >= 10000 = integral abcd
315+pad4 :: Integer -> Builder
316+pad4 abcd | abcd >= 10000 = integerDec abcd
319317 | otherwise = p a ++ p b ++ p c ++ p d
320318 where (ab,cd) = abcd `quotRem` 100
321319 (a,b) = ab `quotRem` 10
src/Database/PostgreSQL/Simple/ToField.hs+43−38
@@ -22,11 +22,14 @@ module Database.PostgreSQL.Simple.ToField
2222 , inQuotes
2323 ) where
2424
25−import Blaze.ByteString.Builder (Builder, fromByteString, toByteString)
26−import Blaze.ByteString.Builder.Char8 (fromChar)
27−import Blaze.Text (integral, double, float)
2825import qualified Data.Aeson as JSON
29−import Data.ByteString (ByteString)
26+import Data.ByteString (ByteString)
27+import Data.ByteString.Builder
28+ ( Builder, byteString, char8, stringUtf8
29+ , intDec, int8Dec, int16Dec, int32Dec, int64Dec, integerDec
30+ , wordDec, word8Dec, word16Dec, word32Dec, word64Dec
31+ , floatDec, doubleDec
32+ )
3033import Data.Int (Int8, Int16, Int32, Int64)
3134import Data.List (intersperse)
3235import Data.Monoid (mappend)
@@ -35,7 +38,8 @@ import Data.Typeable (Typeable)
3538import Data.Word (Word, Word8, Word16, Word32, Word64)
3639import {-# SOURCE #-} Database.PostgreSQL.Simple.ToRow
3740import Database.PostgreSQL.Simple.Types
38−import qualified Blaze.ByteString.Builder.Char.Utf8 as Utf8
41+import Database.PostgreSQL.Simple.Compat (toByteString)
42+
3943import qualified Data.ByteString as SB
4044import qualified Data.ByteString.Lazy as LB
4145import qualified Data.Text as ST
@@ -54,6 +58,7 @@ import Data.Text.Lazy.Builder.Scientific (scientificBuilder)
5458#else
5559import Data.Scientific (scientificBuilder)
5660#endif
61+import Foreign.C.Types (CUInt(..))
5762
5863-- | How to render an element when substituting it into a query.
5964data Action =
@@ -99,84 +104,84 @@ instance (ToField a) => ToField (Maybe a) where
99104 {-# INLINE toField #-}
100105
101106instance (ToField a) => ToField (In [a]) where
102− toField (In []) = Plain $ fromByteString "(null)"
107+ toField (In []) = Plain $ byteString "(null)"
103108 toField (In xs) = Many $
104− Plain (fromChar '(') :
105− (intersperse (Plain (fromChar ',')) . map toField $ xs) ++
106− [Plain (fromChar ')')]
109+ Plain (char8 '(') :
110+ (intersperse (Plain (char8 ',')) . map toField $ xs) ++
111+ [Plain (char8 ')')]
107112
108113renderNull :: Action
109−renderNull = Plain (fromByteString "null")
114+renderNull = Plain (byteString "null")
110115
111116instance ToField Null where
112117 toField _ = renderNull
113118 {-# INLINE toField #-}
114119
115120instance ToField Default where
116− toField _ = Plain (fromByteString "default")
121+ toField _ = Plain (byteString "default")
117122 {-# INLINE toField #-}
118123
119124instance ToField Bool where
120− toField True = Plain (fromByteString "true")
121− toField False = Plain (fromByteString "false")
125+ toField True = Plain (byteString "true")
126+ toField False = Plain (byteString "false")
122127 {-# INLINE toField #-}
123128
124129instance ToField Int8 where
125− toField = Plain . integral
130+ toField = Plain . int8Dec
126131 {-# INLINE toField #-}
127132
128133instance ToField Int16 where
129− toField = Plain . integral
134+ toField = Plain . int16Dec
130135 {-# INLINE toField #-}
131136
132137instance ToField Int32 where
133− toField = Plain . integral
138+ toField = Plain . int32Dec
134139 {-# INLINE toField #-}
135140
136141instance ToField Int where
137− toField = Plain . integral
142+ toField = Plain . intDec
138143 {-# INLINE toField #-}
139144
140145instance ToField Int64 where
141− toField = Plain . integral
146+ toField = Plain . int64Dec
142147 {-# INLINE toField #-}
143148
144149instance ToField Integer where
145− toField = Plain . integral
150+ toField = Plain . integerDec
146151 {-# INLINE toField #-}
147152
148153instance ToField Word8 where
149− toField = Plain . integral
154+ toField = Plain . word8Dec
150155 {-# INLINE toField #-}
151156
152157instance ToField Word16 where
153− toField = Plain . integral
158+ toField = Plain . word16Dec
154159 {-# INLINE toField #-}
155160
156161instance ToField Word32 where
157− toField = Plain . integral
162+ toField = Plain . word32Dec
158163 {-# INLINE toField #-}
159164
160165instance ToField Word where
161− toField = Plain . integral
166+ toField = Plain . wordDec
162167 {-# INLINE toField #-}
163168
164169instance ToField Word64 where
165− toField = Plain . integral
170+ toField = Plain . word64Dec
166171 {-# INLINE toField #-}
167172
168173instance ToField PQ.Oid where
169− toField = Plain . integral . \(PQ.Oid x) -> x
174+ toField = Plain . \(PQ.Oid (CUInt x)) -> word32Dec x
170175 {-# INLINE toField #-}
171176
172177instance ToField Float where
173− toField v | isNaN v || isInfinite v = Plain (inQuotes (float v))
174− | otherwise = Plain (float v)
178+ toField v | isNaN v || isInfinite v = Plain (inQuotes (floatDec v))
179+ | otherwise = Plain (floatDec v)
175180 {-# INLINE toField #-}
176181
177182instance ToField Double where
178− toField v | isNaN v || isInfinite v = Plain (inQuotes (double v))
179− | otherwise = Plain (double v)
183+ toField v | isNaN v || isInfinite v = Plain (inQuotes (doubleDec v))
184+ | otherwise = Plain (doubleDec v)
180185 {-# INLINE toField #-}
181186
182187instance ToField Scientific where
@@ -198,7 +203,7 @@ instance ToField Identifier where
198203instance ToField QualifiedIdentifier where
199204 toField (QualifiedIdentifier (Just s) t) =
200205 Many [ EscapeIdentifier (ST.encodeUtf8 s)
201− , Plain (fromChar '.')
206+ , Plain (char8 '.')
202207 , EscapeIdentifier (ST.encodeUtf8 t)
203208 ]
204209 toField (QualifiedIdentifier Nothing t) =
@@ -218,7 +223,7 @@ instance ToField ST.Text where
218223 {-# INLINE toField #-}
219224
220225instance ToField [Char] where
221− toField = Escape . toByteString . Utf8.fromString
226+ toField = Escape . toByteString . stringUtf8
222227 {-# INLINE toField #-}
223228
224229instance ToField LT.Text where
@@ -268,9 +273,9 @@ instance ToField NominalDiffTime where
268273
269274instance (ToField a) => ToField (PGArray a) where
270275 toField xs = Many $
271− Plain (fromByteString "ARRAY[") :
272− (intersperse (Plain (fromChar ',')) . map toField $ fromPGArray xs) ++
273− [Plain (fromChar ']')]
276+ Plain (byteString "ARRAY[") :
277+ (intersperse (Plain (char8 ',')) . map toField $ fromPGArray xs) ++
278+ [Plain (char8 ']')]
274279 -- Because the ARRAY[...] input syntax is being used, it is possible
275280 -- that the use of type-specific separator characters is unnecessary.
276281
@@ -278,7 +283,7 @@ instance (ToField a) => ToField (Vector a) where
278283 toField = toField . PGArray . V.toList
279284
280285instance ToField UUID where
281− toField = Plain . inQuotes . fromByteString . UUID.toASCIIBytes
286+ toField = Plain . inQuotes . byteString . UUID.toASCIIBytes
282287
283288instance ToField JSON.Value where
284289 toField = toField . JSON.encode
@@ -297,7 +302,7 @@ toJSONField = toField . JSON.toJSON
297302-- This function /does not/ perform any other escaping.
298303inQuotes :: Builder -> Builder
299304inQuotes b = quote `mappend` b `mappend` quote
300− where quote = Utf8.fromChar '\''
305+ where quote = char8 '\''
301306
302307interleaveFoldr :: (a -> [b] -> [b]) -> b -> [b] -> [a] -> [b]
303308interleaveFoldr f b bs as = foldr (\a bs -> b : f a bs) bs as
@@ -318,8 +323,8 @@ instance ToRow a => ToField (Values a) where
318323 funcname = "Database.PostgreSQL.Simple.toField :: Values a -> Action"
319324 norows = funcname ++ " either values or types must be non-empty"
320325 emptyrow = funcname ++ " each row must contain at least one column"
321− lit = Plain . fromByteString
322− litC = Plain . fromChar
326+ lit = Plain . byteString
327+ litC = Plain . char8
323328 values x = Many (lit "(VALUES ": x)
324329
325330 typedField :: (Action, QualifiedIdentifier) -> [Action] -> [Action]
src/Database/PostgreSQL/Simple/ToField.hs-boot+1−1
@@ -1,7 +1,7 @@
11module Database.PostgreSQL.Simple.ToField where
22
33import Database.PostgreSQL.Simple.Types
4−import Blaze.ByteString.Builder(Builder)
4+import Data.ByteString.Builder(Builder)
55import Data.ByteString(ByteString)
66
77-- | How to render an element when substituting it into a query.
src/Database/PostgreSQL/Simple/Types.hs+3−3
@@ -30,18 +30,18 @@ module Database.PostgreSQL.Simple.Types
3030 , Values(..)
3131 ) where
3232
33−import Blaze.ByteString.Builder (toByteString)
3433import Control.Arrow (first)
3534import Data.ByteString (ByteString)
3635import Data.Hashable (Hashable(hashWithSalt))
3736import Data.Monoid (Monoid(..))
3837import Data.String (IsString(..))
3938import Data.Typeable (Typeable)
40−import qualified Blaze.ByteString.Builder.Char.Utf8 as Utf8
39+import Data.ByteString.Builder ( stringUtf8 )
4140import qualified Data.ByteString as B
4241import Data.Text (Text)
4342import qualified Data.Text as T
4443import Database.PostgreSQL.LibPQ (Oid(..))
44+import Database.PostgreSQL.Simple.Compat (toByteString)
4545
4646-- | A placeholder for the SQL @NULL@ value.
4747data Null = Null
@@ -85,7 +85,7 @@ instance Read Query where
8585 readsPrec i = fmap (first Query) . readsPrec i
8686
8787instance IsString Query where
88− fromString = Query . toByteString . Utf8.fromString
88+ fromString = Query . toByteString . stringUtf8
8989
9090instance Monoid Query where
9191 mempty = Query B.empty