postgresql-typed-0.5.1: PostgreSQL interface with compile-time SQL type checking, optional HDBC backend

Copyright2015 Dylan Simon
Safe HaskellNone
LanguageHaskell98

Database.PostgreSQL.Typed.Types

Contents

Description

Classes to support type inference, value encoding/decoding, and instances to support built-in PostgreSQL types.

Synopsis

Basic types

type OID = Word32 #

data PGValue #

A value passed to or from PostgreSQL in raw format.

Constructors

PGNullValue 
PGTextValue

The standard text encoding format (also used for unknown formats)

Fields

PGBinaryValue

Special binary-encoded data. Not supported in all cases.

Fields

type PGValues = [PGValue] #

A list of (nullable) data values, e.g. a single row or query parameters.

data PGTypeID t #

A proxy type for PostgreSQL types. The type argument should be an (internal) name of a database type, as per format_type(OID) (usually the same as \dT+). When the type's namespace (schema) is not in search_path, this will be explicitly qualified, so you should be sure to have a consistent search_path for all database connections. The underlying Symbol should be considered a lifted PGName.

Constructors

PGTypeProxy 

data PGTypeEnv #

Parameters that affect how marshalling happens. Currenly we force all other relevant parameters at connect time. Nothing values represent unknown.

Constructors

PGTypeEnv 

Fields

newtype PGName #

A PostgreSQL literal identifier, generally corresponding to the "name" type (63-byte strings), but as it would be entered in a query, so may include double-quoting for special characters or schema-qualification.

Constructors

PGName 

Fields

Instances

Eq PGName # 

Methods

(==) :: PGName -> PGName -> Bool #

(/=) :: PGName -> PGName -> Bool #

Data PGName # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> PGName -> c PGName #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c PGName #

toConstr :: PGName -> Constr #

dataTypeOf :: PGName -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c PGName) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PGName) #

gmapT :: (forall b. Data b => b -> b) -> PGName -> PGName #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PGName -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PGName -> r #

gmapQ :: (forall d. Data d => d -> u) -> PGName -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> PGName -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> PGName -> m PGName #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> PGName -> m PGName #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> PGName -> m PGName #

Ord PGName # 
Show PGName #

Unquoted pgNameString.

IsString PGName #

Applies utf-8 encoding.

Methods

fromString :: String -> PGName #

PGRep PGName # 

Associated Types

type PGRepType PGName :: Symbol #

PGStringType t => PGColumn t PGName # 

Methods

pgDecode :: PGTypeID t -> PGTextValue -> PGName #

pgDecodeBinary :: PGTypeEnv -> PGTypeID t -> PGBinaryValue -> PGName #

pgDecodeValue :: PGTypeEnv -> PGTypeID t -> PGValue -> PGName #

PGStringType t => PGParameter t PGName # 
type PGRepType PGName # 
type PGRepType PGName = "text"

pgNameBS :: PGName -> ByteString #

The literal identifier as used in a query.

pgNameString :: PGName -> String #

Reverses the IsString instantce.

newtype PGRecord #

Generic class of composite (row or record) types.

Constructors

PGRecord [Maybe PGTextValue] 

Instances

Marshalling classes

class (KnownSymbol t, PGParameter t (PGVal t), PGColumn t (PGVal t)) => PGType t where #

A valid PostgreSQL type, its metadata, and corresponding Haskell representation. For conversion the other way (from Haskell type to PostgreSQL), see PGRep. Unfortunately any instances of this will be orphans.

Associated Types

type PGVal t :: * #

The default, native Haskell representation of this type, which should be as close as possible to the PostgreSQL representation.

Methods

pgTypeName :: PGTypeID t -> PGName #

The string name of this type: specialized version of symbolVal.

pgBinaryColumn :: PGTypeEnv -> PGTypeID t -> Bool #

Does this type support binary decoding? If so, pgDecodeBinary must be implemented for every PGColumn instance of this type.

Instances

PGType "\"char\"" # 

Associated Types

type PGVal ("\"char\"" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "\"char\"" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "\"char\"" -> Bool #

PGType "any" # 

Associated Types

type PGVal ("any" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "any" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "any" -> Bool #

PGType "bigint" # 

Associated Types

type PGVal ("bigint" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "bigint" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "bigint" -> Bool #

PGType "boolean" # 

Associated Types

type PGVal ("boolean" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "boolean" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "boolean" -> Bool #

PGType "bpchar" # 

Associated Types

type PGVal ("bpchar" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "bpchar" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "bpchar" -> Bool #

PGType "bytea" # 

Associated Types

type PGVal ("bytea" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "bytea" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "bytea" -> Bool #

PGType "character varying" # 

Associated Types

type PGVal ("character varying" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "character varying" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "character varying" -> Bool #

PGType "date" # 

Associated Types

type PGVal ("date" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "date" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "date" -> Bool #

PGType "double precision" # 

Associated Types

type PGVal ("double precision" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "double precision" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "double precision" -> Bool #

PGType "integer" # 

Associated Types

type PGVal ("integer" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "integer" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "integer" -> Bool #

PGType "interval" # 

Associated Types

type PGVal ("interval" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "interval" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "interval" -> Bool #

PGType "json" # 

Associated Types

type PGVal ("json" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "json" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "json" -> Bool #

PGType "jsonb" # 

Associated Types

type PGVal ("jsonb" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "jsonb" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "jsonb" -> Bool #

PGType "name" # 

Associated Types

type PGVal ("name" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "name" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "name" -> Bool #

PGType "numeric" # 

Associated Types

type PGVal ("numeric" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "numeric" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "numeric" -> Bool #

PGType "oid" # 

Associated Types

type PGVal ("oid" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "oid" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "oid" -> Bool #

PGType "real" # 

Associated Types

type PGVal ("real" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "real" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "real" -> Bool #

PGType "record" # 

Associated Types

type PGVal ("record" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "record" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "record" -> Bool #

PGType "smallint" # 

Associated Types

type PGVal ("smallint" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "smallint" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "smallint" -> Bool #

PGType "text" # 

Associated Types

type PGVal ("text" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "text" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "text" -> Bool #

PGType "time with time zone" # 

Associated Types

type PGVal ("time with time zone" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "time with time zone" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "time with time zone" -> Bool #

PGType "time without time zone" # 

Associated Types

type PGVal ("time without time zone" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "time without time zone" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "time without time zone" -> Bool #

PGType "timestamp with time zone" # 

Associated Types

type PGVal ("timestamp with time zone" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "timestamp with time zone" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "timestamp with time zone" -> Bool #

PGType "timestamp without time zone" # 

Associated Types

type PGVal ("timestamp without time zone" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "timestamp without time zone" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "timestamp without time zone" -> Bool #

PGType "uuid" # 

Associated Types

type PGVal ("uuid" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "uuid" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "uuid" -> Bool #

PGType "void" # 

Associated Types

type PGVal ("void" :: Symbol) :: * #

Methods

pgTypeName :: PGTypeID "void" -> PGName #

pgBinaryColumn :: PGTypeEnv -> PGTypeID "void" -> Bool #

class PGType t => PGParameter t a where #

A PGParameter t a instance describes how to encode a PostgreSQL type t from a.

Minimal complete definition

pgEncode

Methods

pgEncode :: PGTypeID t -> a -> PGTextValue #

Encode a value to a PostgreSQL text representation.

pgLiteral :: PGTypeID t -> a -> ByteString #

Encode a value to a (quoted) literal value for use in SQL statements. Defaults to a quoted version of pgEncode

pgEncodeValue :: PGTypeEnv -> PGTypeID t -> a -> PGValue #

Encode a value to a PostgreSQL representation. Defaults to the text representation by pgEncode

Instances

PGRecordType t => PGParameter t PGRecord # 
PGStringType t => PGParameter t Text # 

Methods

pgEncode :: PGTypeID t -> Text -> PGTextValue #

pgLiteral :: PGTypeID t -> Text -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID t -> Text -> PGValue #

PGStringType t => PGParameter t Text # 

Methods

pgEncode :: PGTypeID t -> Text -> PGTextValue #

pgLiteral :: PGTypeID t -> Text -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID t -> Text -> PGValue #

PGStringType t => PGParameter t ByteString # 
PGStringType t => PGParameter t PGName # 
PGStringType t => PGParameter t ByteString # 
PGStringType t => PGParameter t String # 
PGParameter "\"char\"" Char # 

Methods

pgEncode :: PGTypeID "\"char\"" -> Char -> PGTextValue #

pgLiteral :: PGTypeID "\"char\"" -> Char -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "\"char\"" -> Char -> PGValue #

PGParameter "\"char\"" Word8 # 

Methods

pgEncode :: PGTypeID "\"char\"" -> Word8 -> PGTextValue #

pgLiteral :: PGTypeID "\"char\"" -> Word8 -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "\"char\"" -> Word8 -> PGValue #

PGParameter "any" PGValue # 

Methods

pgEncode :: PGTypeID "any" -> PGValue -> PGTextValue #

pgLiteral :: PGTypeID "any" -> PGValue -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "any" -> PGValue -> PGValue #

PGParameter "bigint" Int64 # 

Methods

pgEncode :: PGTypeID "bigint" -> Int64 -> PGTextValue #

pgLiteral :: PGTypeID "bigint" -> Int64 -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "bigint" -> Int64 -> PGValue #

PGParameter "boolean" Bool # 

Methods

pgEncode :: PGTypeID "boolean" -> Bool -> PGTextValue #

pgLiteral :: PGTypeID "boolean" -> Bool -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "boolean" -> Bool -> PGValue #

PGParameter "bytea" ByteString # 

Methods

pgEncode :: PGTypeID "bytea" -> ByteString -> PGTextValue #

pgLiteral :: PGTypeID "bytea" -> ByteString -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "bytea" -> ByteString -> PGValue #

PGParameter "bytea" ByteString # 

Methods

pgEncode :: PGTypeID "bytea" -> ByteString -> PGTextValue #

pgLiteral :: PGTypeID "bytea" -> ByteString -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "bytea" -> ByteString -> PGValue #

PGParameter "cidr" PGInet # 

Methods

pgEncode :: PGTypeID "cidr" -> PGInet -> PGTextValue #

pgLiteral :: PGTypeID "cidr" -> PGInet -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "cidr" -> PGInet -> PGValue #

PGParameter "date" Day # 

Methods

pgEncode :: PGTypeID "date" -> Day -> PGTextValue #

pgLiteral :: PGTypeID "date" -> Day -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "date" -> Day -> PGValue #

PGParameter "double precision" Double # 

Methods

pgEncode :: PGTypeID "double precision" -> Double -> PGTextValue #

pgLiteral :: PGTypeID "double precision" -> Double -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "double precision" -> Double -> PGValue #

PGParameter "double precision" Float # 

Methods

pgEncode :: PGTypeID "double precision" -> Float -> PGTextValue #

pgLiteral :: PGTypeID "double precision" -> Float -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "double precision" -> Float -> PGValue #

PGParameter "inet" PGInet # 

Methods

pgEncode :: PGTypeID "inet" -> PGInet -> PGTextValue #

pgLiteral :: PGTypeID "inet" -> PGInet -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "inet" -> PGInet -> PGValue #

PGParameter "integer" Int32 # 

Methods

pgEncode :: PGTypeID "integer" -> Int32 -> PGTextValue #

pgLiteral :: PGTypeID "integer" -> Int32 -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "integer" -> Int32 -> PGValue #

PGParameter "interval" DiffTime # 

Methods

pgEncode :: PGTypeID "interval" -> DiffTime -> PGTextValue #

pgLiteral :: PGTypeID "interval" -> DiffTime -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "interval" -> DiffTime -> PGValue #

PGParameter "json" Value # 

Methods

pgEncode :: PGTypeID "json" -> Value -> PGTextValue #

pgLiteral :: PGTypeID "json" -> Value -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "json" -> Value -> PGValue #

PGParameter "jsonb" Value # 

Methods

pgEncode :: PGTypeID "jsonb" -> Value -> PGTextValue #

pgLiteral :: PGTypeID "jsonb" -> Value -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "jsonb" -> Value -> PGValue #

PGParameter "numeric" Rational # 

Methods

pgEncode :: PGTypeID "numeric" -> Rational -> PGTextValue #

pgLiteral :: PGTypeID "numeric" -> Rational -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "numeric" -> Rational -> PGValue #

PGParameter "numeric" Scientific # 

Methods

pgEncode :: PGTypeID "numeric" -> Scientific -> PGTextValue #

pgLiteral :: PGTypeID "numeric" -> Scientific -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "numeric" -> Scientific -> PGValue #

PGParameter "oid" OID # 

Methods

pgEncode :: PGTypeID "oid" -> OID -> PGTextValue #

pgLiteral :: PGTypeID "oid" -> OID -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "oid" -> OID -> PGValue #

PGParameter "real" Float # 

Methods

pgEncode :: PGTypeID "real" -> Float -> PGTextValue #

pgLiteral :: PGTypeID "real" -> Float -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "real" -> Float -> PGValue #

PGParameter "smallint" Int16 # 

Methods

pgEncode :: PGTypeID "smallint" -> Int16 -> PGTextValue #

pgLiteral :: PGTypeID "smallint" -> Int16 -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "smallint" -> Int16 -> PGValue #

PGParameter "time without time zone" TimeOfDay # 

Methods

pgEncode :: PGTypeID "time without time zone" -> TimeOfDay -> PGTextValue #

pgLiteral :: PGTypeID "time without time zone" -> TimeOfDay -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "time without time zone" -> TimeOfDay -> PGValue #

PGParameter "timestamp with time zone" UTCTime # 

Methods

pgEncode :: PGTypeID "timestamp with time zone" -> UTCTime -> PGTextValue #

pgLiteral :: PGTypeID "timestamp with time zone" -> UTCTime -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "timestamp with time zone" -> UTCTime -> PGValue #

PGParameter "timestamp without time zone" LocalTime # 

Methods

pgEncode :: PGTypeID "timestamp without time zone" -> LocalTime -> PGTextValue #

pgLiteral :: PGTypeID "timestamp without time zone" -> LocalTime -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "timestamp without time zone" -> LocalTime -> PGValue #

PGParameter "uuid" UUID # 

Methods

pgEncode :: PGTypeID "uuid" -> UUID -> PGTextValue #

pgLiteral :: PGTypeID "uuid" -> UUID -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "uuid" -> UUID -> PGValue #

PGParameter "void" () # 

Methods

pgEncode :: PGTypeID "void" -> () -> PGTextValue #

pgLiteral :: PGTypeID "void" -> () -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "void" -> () -> PGValue #

PGParameter t a => PGParameter t (Maybe a) # 

Methods

pgEncode :: PGTypeID t -> Maybe a -> PGTextValue #

pgLiteral :: PGTypeID t -> Maybe a -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID t -> Maybe a -> PGValue #

(PGRangeType t, PGParameter (PGSubType t) a) => PGParameter t (Range a) # 

Methods

pgEncode :: PGTypeID t -> Range a -> PGTextValue #

pgLiteral :: PGTypeID t -> Range a -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID t -> Range a -> PGValue #

PGParameter "time with time zone" (TimeOfDay, TimeZone) # 

Methods

pgEncode :: PGTypeID "time with time zone" -> (TimeOfDay, TimeZone) -> PGTextValue #

pgLiteral :: PGTypeID "time with time zone" -> (TimeOfDay, TimeZone) -> ByteString #

pgEncodeValue :: PGTypeEnv -> PGTypeID "time with time zone" -> (TimeOfDay, TimeZone) -> PGValue #

class PGType t => PGColumn t a where #

A PGColumn t a instance describes how te decode a PostgreSQL type t to a.

Minimal complete definition

pgDecode

Methods

pgDecode :: PGTypeID t -> PGTextValue -> a #

Decode the PostgreSQL text representation into a value.

pgDecodeBinary :: PGTypeEnv -> PGTypeID t -> PGBinaryValue -> a #

Decode the PostgreSQL binary representation into a value. Only needs to be implemented if pgBinaryColumn is true.

pgDecodeValue :: PGTypeEnv -> PGTypeID t -> PGValue -> a #

Instances

PGRecordType t => PGColumn t PGRecord # 

Methods

pgDecode :: PGTypeID t -> PGTextValue -> PGRecord #

pgDecodeBinary :: PGTypeEnv -> PGTypeID t -> PGBinaryValue -> PGRecord #

pgDecodeValue :: PGTypeEnv -> PGTypeID t -> PGValue -> PGRecord #

PGStringType t => PGColumn t Text # 

Methods

pgDecode :: PGTypeID t -> PGTextValue -> Text #

pgDecodeBinary :: PGTypeEnv -> PGTypeID t -> PGBinaryValue -> Text #

pgDecodeValue :: PGTypeEnv -> PGTypeID t -> PGValue -> Text #

PGStringType t => PGColumn t Text # 

Methods

pgDecode :: PGTypeID t -> PGTextValue -> Text #

pgDecodeBinary :: PGTypeEnv -> PGTypeID t -> PGBinaryValue -> Text #

pgDecodeValue :: PGTypeEnv -> PGTypeID t -> PGValue -> Text #

PGStringType t => PGColumn t ByteString # 

Methods

pgDecode :: PGTypeID t -> PGTextValue -> ByteString #

pgDecodeBinary :: PGTypeEnv -> PGTypeID t -> PGBinaryValue -> ByteString #

pgDecodeValue :: PGTypeEnv -> PGTypeID t -> PGValue -> ByteString #

PGStringType t => PGColumn t PGName # 

Methods

pgDecode :: PGTypeID t -> PGTextValue -> PGName #

pgDecodeBinary :: PGTypeEnv -> PGTypeID t -> PGBinaryValue -> PGName #

pgDecodeValue :: PGTypeEnv -> PGTypeID t -> PGValue -> PGName #

PGStringType t => PGColumn t ByteString # 

Methods

pgDecode :: PGTypeID t -> PGTextValue -> ByteString #

pgDecodeBinary :: PGTypeEnv -> PGTypeID t -> PGBinaryValue -> ByteString #

pgDecodeValue :: PGTypeEnv -> PGTypeID t -> PGValue -> ByteString #

PGStringType t => PGColumn t String # 

Methods

pgDecode :: PGTypeID t -> PGTextValue -> String #

pgDecodeBinary :: PGTypeEnv -> PGTypeID t -> PGBinaryValue -> String #

pgDecodeValue :: PGTypeEnv -> PGTypeID t -> PGValue -> String #

PGType t => PGColumn t PGValue # 

Methods

pgDecode :: PGTypeID t -> PGTextValue -> PGValue #

pgDecodeBinary :: PGTypeEnv -> PGTypeID t -> PGBinaryValue -> PGValue #

pgDecodeValue :: PGTypeEnv -> PGTypeID t -> PGValue -> PGValue #

PGColumn "\"char\"" Char # 

Methods

pgDecode :: PGTypeID "\"char\"" -> PGTextValue -> Char #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "\"char\"" -> PGBinaryValue -> Char #

pgDecodeValue :: PGTypeEnv -> PGTypeID "\"char\"" -> PGValue -> Char #

PGColumn "\"char\"" Word8 # 

Methods

pgDecode :: PGTypeID "\"char\"" -> PGTextValue -> Word8 #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "\"char\"" -> PGBinaryValue -> Word8 #

pgDecodeValue :: PGTypeEnv -> PGTypeID "\"char\"" -> PGValue -> Word8 #

PGColumn "bigint" Int64 # 

Methods

pgDecode :: PGTypeID "bigint" -> PGTextValue -> Int64 #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "bigint" -> PGBinaryValue -> Int64 #

pgDecodeValue :: PGTypeEnv -> PGTypeID "bigint" -> PGValue -> Int64 #

PGColumn "boolean" Bool # 

Methods

pgDecode :: PGTypeID "boolean" -> PGTextValue -> Bool #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "boolean" -> PGBinaryValue -> Bool #

pgDecodeValue :: PGTypeEnv -> PGTypeID "boolean" -> PGValue -> Bool #

PGColumn "bytea" ByteString # 

Methods

pgDecode :: PGTypeID "bytea" -> PGTextValue -> ByteString #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "bytea" -> PGBinaryValue -> ByteString #

pgDecodeValue :: PGTypeEnv -> PGTypeID "bytea" -> PGValue -> ByteString #

PGColumn "bytea" ByteString # 

Methods

pgDecode :: PGTypeID "bytea" -> PGTextValue -> ByteString #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "bytea" -> PGBinaryValue -> ByteString #

pgDecodeValue :: PGTypeEnv -> PGTypeID "bytea" -> PGValue -> ByteString #

PGColumn "cidr" PGInet # 

Methods

pgDecode :: PGTypeID "cidr" -> PGTextValue -> PGInet #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "cidr" -> PGBinaryValue -> PGInet #

pgDecodeValue :: PGTypeEnv -> PGTypeID "cidr" -> PGValue -> PGInet #

PGColumn "date" Day # 

Methods

pgDecode :: PGTypeID "date" -> PGTextValue -> Day #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "date" -> PGBinaryValue -> Day #

pgDecodeValue :: PGTypeEnv -> PGTypeID "date" -> PGValue -> Day #

PGColumn "double precision" Double # 

Methods

pgDecode :: PGTypeID "double precision" -> PGTextValue -> Double #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "double precision" -> PGBinaryValue -> Double #

pgDecodeValue :: PGTypeEnv -> PGTypeID "double precision" -> PGValue -> Double #

PGColumn "inet" PGInet # 

Methods

pgDecode :: PGTypeID "inet" -> PGTextValue -> PGInet #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "inet" -> PGBinaryValue -> PGInet #

pgDecodeValue :: PGTypeEnv -> PGTypeID "inet" -> PGValue -> PGInet #

PGColumn "integer" Int32 # 

Methods

pgDecode :: PGTypeID "integer" -> PGTextValue -> Int32 #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "integer" -> PGBinaryValue -> Int32 #

pgDecodeValue :: PGTypeEnv -> PGTypeID "integer" -> PGValue -> Int32 #

PGColumn "interval" DiffTime #

Representation of DiffTime as interval. PostgreSQL stores months and days separately in intervals, but DiffTime does not. We collapse all interval fields into seconds

Methods

pgDecode :: PGTypeID "interval" -> PGTextValue -> DiffTime #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "interval" -> PGBinaryValue -> DiffTime #

pgDecodeValue :: PGTypeEnv -> PGTypeID "interval" -> PGValue -> DiffTime #

PGColumn "json" Value # 

Methods

pgDecode :: PGTypeID "json" -> PGTextValue -> Value #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "json" -> PGBinaryValue -> Value #

pgDecodeValue :: PGTypeEnv -> PGTypeID "json" -> PGValue -> Value #

PGColumn "jsonb" Value # 

Methods

pgDecode :: PGTypeID "jsonb" -> PGTextValue -> Value #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "jsonb" -> PGBinaryValue -> Value #

pgDecodeValue :: PGTypeEnv -> PGTypeID "jsonb" -> PGValue -> Value #

PGColumn "numeric" Rational #

High-precision representation of Rational as numeric. Unfortunately, numeric has an NaN, while Rational does not. NaN numeric values will produce exceptions.

Methods

pgDecode :: PGTypeID "numeric" -> PGTextValue -> Rational #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "numeric" -> PGBinaryValue -> Rational #

pgDecodeValue :: PGTypeEnv -> PGTypeID "numeric" -> PGValue -> Rational #

PGColumn "numeric" Scientific # 

Methods

pgDecode :: PGTypeID "numeric" -> PGTextValue -> Scientific #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "numeric" -> PGBinaryValue -> Scientific #

pgDecodeValue :: PGTypeEnv -> PGTypeID "numeric" -> PGValue -> Scientific #

PGColumn "oid" OID # 

Methods

pgDecode :: PGTypeID "oid" -> PGTextValue -> OID #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "oid" -> PGBinaryValue -> OID #

pgDecodeValue :: PGTypeEnv -> PGTypeID "oid" -> PGValue -> OID #

PGColumn "real" Double # 

Methods

pgDecode :: PGTypeID "real" -> PGTextValue -> Double #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "real" -> PGBinaryValue -> Double #

pgDecodeValue :: PGTypeEnv -> PGTypeID "real" -> PGValue -> Double #

PGColumn "real" Float # 

Methods

pgDecode :: PGTypeID "real" -> PGTextValue -> Float #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "real" -> PGBinaryValue -> Float #

pgDecodeValue :: PGTypeEnv -> PGTypeID "real" -> PGValue -> Float #

PGColumn "smallint" Int16 # 

Methods

pgDecode :: PGTypeID "smallint" -> PGTextValue -> Int16 #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "smallint" -> PGBinaryValue -> Int16 #

pgDecodeValue :: PGTypeEnv -> PGTypeID "smallint" -> PGValue -> Int16 #

PGColumn "time without time zone" TimeOfDay # 

Methods

pgDecode :: PGTypeID "time without time zone" -> PGTextValue -> TimeOfDay #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "time without time zone" -> PGBinaryValue -> TimeOfDay #

pgDecodeValue :: PGTypeEnv -> PGTypeID "time without time zone" -> PGValue -> TimeOfDay #

PGColumn "timestamp with time zone" UTCTime # 

Methods

pgDecode :: PGTypeID "timestamp with time zone" -> PGTextValue -> UTCTime #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "timestamp with time zone" -> PGBinaryValue -> UTCTime #

pgDecodeValue :: PGTypeEnv -> PGTypeID "timestamp with time zone" -> PGValue -> UTCTime #

PGColumn "timestamp without time zone" LocalTime # 

Methods

pgDecode :: PGTypeID "timestamp without time zone" -> PGTextValue -> LocalTime #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "timestamp without time zone" -> PGBinaryValue -> LocalTime #

pgDecodeValue :: PGTypeEnv -> PGTypeID "timestamp without time zone" -> PGValue -> LocalTime #

PGColumn "uuid" UUID # 

Methods

pgDecode :: PGTypeID "uuid" -> PGTextValue -> UUID #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "uuid" -> PGBinaryValue -> UUID #

pgDecodeValue :: PGTypeEnv -> PGTypeID "uuid" -> PGValue -> UUID #

PGColumn "void" () # 

Methods

pgDecode :: PGTypeID "void" -> PGTextValue -> () #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "void" -> PGBinaryValue -> () #

pgDecodeValue :: PGTypeEnv -> PGTypeID "void" -> PGValue -> () #

PGColumn t a => PGColumn t (Maybe a) # 

Methods

pgDecode :: PGTypeID t -> PGTextValue -> Maybe a #

pgDecodeBinary :: PGTypeEnv -> PGTypeID t -> PGBinaryValue -> Maybe a #

pgDecodeValue :: PGTypeEnv -> PGTypeID t -> PGValue -> Maybe a #

(PGRangeType t, PGColumn (PGSubType t) a) => PGColumn t (Range a) # 

Methods

pgDecode :: PGTypeID t -> PGTextValue -> Range a #

pgDecodeBinary :: PGTypeEnv -> PGTypeID t -> PGBinaryValue -> Range a #

pgDecodeValue :: PGTypeEnv -> PGTypeID t -> PGValue -> Range a #

PGColumn "time with time zone" (TimeOfDay, TimeZone) # 

Methods

pgDecode :: PGTypeID "time with time zone" -> PGTextValue -> (TimeOfDay, TimeZone) #

pgDecodeBinary :: PGTypeEnv -> PGTypeID "time with time zone" -> PGBinaryValue -> (TimeOfDay, TimeZone) #

pgDecodeValue :: PGTypeEnv -> PGTypeID "time with time zone" -> PGValue -> (TimeOfDay, TimeZone) #

class PGType t => PGStringType t #

Instances

PGStringType "bpchar" # 
PGStringType "character varying" # 
PGStringType "name" # 
PGStringType "text" # 

class PGType t => PGRecordType t #

Instances

PGRecordType "record" #

The generic anonymous record type, as created by ROW. In this case we can not know the types, and in fact, PostgreSQL does not accept values of this type regardless (except as literals).

Marshalling interface

pgEncodeParameter :: PGParameter t a => PGTypeEnv -> PGTypeID t -> a -> PGValue #

Final parameter encoding function used when a (nullable) parameter is passed to a prepared query.

pgEscapeParameter :: PGParameter t a => PGTypeEnv -> PGTypeID t -> a -> ByteString #

Final parameter escaping function used when a (nullable) parameter is passed to be substituted into a simple query.

pgDecodeColumn :: PGColumn t (Maybe a) => PGTypeEnv -> PGTypeID t -> PGValue -> Maybe a #

Final column decoding function used for a nullable result value.

pgDecodeColumnNotNull :: PGColumn t a => PGTypeEnv -> PGTypeID t -> PGValue -> a #

Final column decoding function used for a non-nullable result value.

Conversion utilities

pgQuote :: ByteString -> ByteString #

Produce a SQL string literal by wrapping (and escaping) a string with single quotes.

pgDQuote :: [Char] -> ByteString -> Builder #

Double-quote a value if it's "", "null", or contains any whitespace, '"', '\', or the characters given in the first argument. Checking all these things may not be worth it. We could just double-quote everything.

parsePGDQuote :: Bool -> [Char] -> (ByteString -> Bool) -> Parser (Maybe ByteString) #

Parse double-quoted values ala pgDQuote.