Revert "Migrate to new text-builder"

This reverts commit d9bf8c8cea.
This commit is contained in:
Nikita Volkov 2021-11-02 10:26:35 +03:00
parent f499590a16
commit 7f1c0cfb9b
6 changed files with 11 additions and 15 deletions

View File

@ -67,7 +67,7 @@ library
postgresql-libpq ==0.9.*, postgresql-libpq ==0.9.*,
profunctors >=5.1 && <6, profunctors >=5.1 && <6,
text >=1 && <2, text >=1 && <2,
text-builder >=0.7 && <0.8, text-builder >=0.6.1.2 && <0.7,
transformers >=0.3 && <0.6, transformers >=0.3 && <0.6,
vector >=0.10 && <0.13 vector >=0.10 && <0.13

View File

@ -7,7 +7,7 @@ where
import Hasql.Private.Prelude hiding (bool) import Hasql.Private.Prelude hiding (bool)
import qualified PostgreSQL.Binary.Encoding as A import qualified PostgreSQL.Binary.Encoding as A
import qualified PostgreSQL.Binary.Data as B import qualified PostgreSQL.Binary.Data as B
import qualified TextBuilder as C import qualified Text.Builder as C
import qualified Hasql.Private.Encoders.Params as Params import qualified Hasql.Private.Encoders.Params as Params
import qualified Hasql.Private.Encoders.Value as Value import qualified Hasql.Private.Encoders.Value as Value
import qualified Hasql.Private.Encoders.Array as Array import qualified Hasql.Private.Encoders.Array as Array

View File

@ -3,23 +3,23 @@ module Hasql.Private.Encoders.Array where
import Hasql.Private.Prelude import Hasql.Private.Prelude
import qualified PostgreSQL.Binary.Encoding as A import qualified PostgreSQL.Binary.Encoding as A
import qualified Hasql.Private.PTI as B import qualified Hasql.Private.PTI as B
import qualified TextBuilder as C import qualified Text.Builder as C
data Array a = data Array a =
Array B.OID B.OID (Bool -> a -> A.Array) (a -> C.TextBuilder) Array B.OID B.OID (Bool -> a -> A.Array) (a -> C.Builder)
instance Contravariant Array where instance Contravariant Array where
contramap fn (Array valueOid arrayOid encoder renderer) = contramap fn (Array valueOid arrayOid encoder renderer) =
Array valueOid arrayOid (\ intDateTimes -> encoder intDateTimes . fn) (renderer . fn) Array valueOid arrayOid (\ intDateTimes -> encoder intDateTimes . fn) (renderer . fn)
{-# INLINE value #-} {-# INLINE value #-}
value :: B.OID -> B.OID -> (Bool -> a -> A.Encoding) -> (a -> C.TextBuilder) -> Array a value :: B.OID -> B.OID -> (Bool -> a -> A.Encoding) -> (a -> C.Builder) -> Array a
value valueOID arrayOID encoder = value valueOID arrayOID encoder =
Array valueOID arrayOID (\params -> A.encodingArray . encoder params) Array valueOID arrayOID (\params -> A.encodingArray . encoder params)
{-# INLINE nullableValue #-} {-# INLINE nullableValue #-}
nullableValue :: B.OID -> B.OID -> (Bool -> a -> A.Encoding) -> (a -> C.TextBuilder) -> Array (Maybe a) nullableValue :: B.OID -> B.OID -> (Bool -> a -> A.Encoding) -> (a -> C.Builder) -> Array (Maybe a)
nullableValue valueOID arrayOID encoder renderer = nullableValue valueOID arrayOID encoder renderer =
let let
maybeEncoder params = maybeEncoder params =

View File

@ -5,7 +5,7 @@ import qualified Database.PostgreSQL.LibPQ as A
import qualified PostgreSQL.Binary.Encoding as B import qualified PostgreSQL.Binary.Encoding as B
import qualified Hasql.Private.Encoders.Value as C import qualified Hasql.Private.Encoders.Value as C
import qualified Hasql.Private.PTI as D import qualified Hasql.Private.PTI as D
import qualified TextBuilder as E import qualified Text.Builder as E
-- | -- |
@ -27,5 +27,5 @@ nullableValue (C.Value valueOID arrayOID encode render) =
encoder env = encoder env =
fmap (B.encodingBytes . encode env) input fmap (B.encodingBytes . encode env) input
rendering = rendering =
maybe "null" (E.buildText . render) input maybe "null" (E.run . render) input
in pure (pqOid, format, encoder, rendering) in pure (pqOid, format, encoder, rendering)

View File

@ -3,11 +3,11 @@ module Hasql.Private.Encoders.Value where
import Hasql.Private.Prelude import Hasql.Private.Prelude
import qualified PostgreSQL.Binary.Encoding as B import qualified PostgreSQL.Binary.Encoding as B
import qualified Hasql.Private.PTI as PTI import qualified Hasql.Private.PTI as PTI
import qualified TextBuilder as C import qualified Text.Builder as C
data Value a = data Value a =
Value PTI.OID PTI.OID (Bool -> a -> B.Encoding) (a -> C.TextBuilder) Value PTI.OID PTI.OID (Bool -> a -> B.Encoding) (a -> C.Builder)
instance Contravariant Value where instance Contravariant Value where
{-# INLINE contramap #-} {-# INLINE contramap #-}
@ -15,7 +15,7 @@ instance Contravariant Value where
Value valueOID arrayOID (\integerDatetimes input -> encode integerDatetimes (f input)) (render . f) Value valueOID arrayOID (\integerDatetimes input -> encode integerDatetimes (f input)) (render . f)
{-# INLINE unsafePTI #-} {-# INLINE unsafePTI #-}
unsafePTI :: PTI.PTI -> (Bool -> a -> B.Encoding) -> (a -> C.TextBuilder) -> Value a unsafePTI :: PTI.PTI -> (Bool -> a -> B.Encoding) -> (a -> C.Builder) -> Value a
unsafePTI pti = unsafePTI pti =
Value (PTI.ptiOID pti) (fromMaybe (error "No array OID") (PTI.ptiArrayOID pti)) Value (PTI.ptiOID pti) (fromMaybe (error "No array OID") (PTI.ptiArrayOID pti))

View File

@ -1,4 +0,0 @@
resolver: nightly-2021-10-18
extra-deps:
- git: https://github.com/nikita-volkov/text-builder
commit: c13872edc976fac70231af5cc3bd13763c001f20