Support for inet data type.

This commit is contained in:
Rik van der Kleij 2017-03-14 16:11:42 +01:00
parent b258dfe13e
commit 85e4c7a686
3 changed files with 21 additions and 3 deletions

View File

@ -74,7 +74,7 @@ library
-- parsing: -- parsing:
attoparsec >= 0.10 && < 0.14, attoparsec >= 0.10 && < 0.14,
-- database: -- database:
postgresql-binary >= 0.9.1.1 && < 0.10, postgresql-binary >= 0.9.1.1 && < 1,
postgresql-libpq == 0.9.*, postgresql-libpq == 0.9.*,
-- builders: -- builders:
bytestring-tree-builder >= 0.2.5 && < 0.3, bytestring-tree-builder >= 0.2.5 && < 0.3,
@ -89,6 +89,7 @@ library
text >= 1 && < 2, text >= 1 && < 2,
bytestring >= 0.10 && < 0.11, bytestring >= 0.10 && < 0.11,
hashable >= 1.2 && < 1.3, hashable >= 1.2 && < 1.3,
network-ip >= 0.2 && < 1,
-- control: -- control:
semigroups >= 0.18 && < 0.20, semigroups >= 0.18 && < 0.20,
data-default-class >= 0.0.1 && < 0.2, data-default-class >= 0.0.1 && < 0.2,

View File

@ -37,6 +37,7 @@ module Hasql.Decoders
timetz, timetz,
interval, interval,
uuid, uuid,
inet,
json, json,
jsonBytes, jsonBytes,
jsonb, jsonb,
@ -69,7 +70,7 @@ import qualified Hasql.Private.Decoders.Value as Value
import qualified Hasql.Private.Decoders.Array as Array import qualified Hasql.Private.Decoders.Array as Array
import qualified Hasql.Private.Decoders.Composite as Composite import qualified Hasql.Private.Decoders.Composite as Composite
import qualified Hasql.Private.Prelude as Prelude import qualified Hasql.Private.Prelude as Prelude
import qualified Network.IP.Addr as IPAddr
-- * Result -- * Result
------------------------- -------------------------
@ -415,6 +416,14 @@ uuid :: Value UUID
uuid = uuid =
Value (Value.decoder (const Decoder.uuid)) Value (Value.decoder (const Decoder.uuid))
-- |
-- Decoder of the @INET@ values.
--
{-# INLINABLE inet #-}
inet :: Value (IPAddr.NetAddr IPAddr.IP)
inet =
Value (Value.decoder (const Decoder.inet))
-- | -- |
-- Decoder of the @JSON@ values into a JSON AST. -- Decoder of the @JSON@ values into a JSON AST.
-- --

View File

@ -26,6 +26,7 @@ module Hasql.Encoders
timetz, timetz,
interval, interval,
uuid, uuid,
inet,
json, json,
jsonBytes, jsonBytes,
jsonb, jsonb,
@ -49,7 +50,7 @@ import qualified Hasql.Private.Encoders.Value as Value
import qualified Hasql.Private.Encoders.Array as Array import qualified Hasql.Private.Encoders.Array as Array
import qualified Hasql.Private.PTI as PTI import qualified Hasql.Private.PTI as PTI
import qualified Hasql.Private.Prelude as Prelude import qualified Hasql.Private.Prelude as Prelude
import qualified Network.IP.Addr as IPAddr
-- * Parameters Product Encoder -- * Parameters Product Encoder
------------------------- -------------------------
@ -301,6 +302,13 @@ uuid :: Value UUID
uuid = uuid =
Value (Value.unsafePTI PTI.uuid (const Encoder.uuid)) Value (Value.unsafePTI PTI.uuid (const Encoder.uuid))
-- |
-- Encoder of @INET@ values.
{-# INLINABLE inet #-}
inet :: Value (IPAddr.NetAddr IPAddr.IP)
inet =
Value (Value.unsafePTI PTI.inet (const Encoder.inet))
-- | -- |
-- Encoder of @JSON@ values from JSON AST. -- Encoder of @JSON@ values from JSON AST.
{-# INLINABLE json #-} {-# INLINABLE json #-}