postgresql-typed-0.5.2: 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

data PGValue Source #

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] Source #

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

data PGTypeID t Source #

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 Source #

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 Source #

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 Source # 

Methods

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

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

Data PGName Source # 

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 Source # 
Show PGName Source #

Unquoted pgNameString.

IsString PGName Source #

Applies utf-8 encoding.

Methods

fromString :: String -> PGName #

PGRep PGName Source # 

Associated Types

type PGRepType PGName :: Symbol Source #

PGStringType t => PGColumn t PGName Source # 

Methods

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

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

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

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

pgNameBS :: PGName -> ByteString Source #

The literal identifier as used in a query.

pgNameString :: PGName -> String Source #

Reverses the IsString instantce.

newtype PGRecord Source #

Generic class of composite (row or record) types.

Constructors

PGRecord [Maybe PGTextValue] 

Marshalling classes

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

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 :: * Source #

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

Methods

pgTypeName :: PGTypeID t -> PGName Source #

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

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

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

Instances

PGType "\"char\"" Source # 

Associated Types

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

Methods

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

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

PGType "any" Source # 

Associated Types

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

PGType "bigint" Source # 

Associated Types

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

Methods

pgTypeName :: PGTypeID "bigint" -> PGName Source #

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

PGType "boolean" Source # 

Associated Types

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

Methods

pgTypeName :: PGTypeID "boolean" -> PGName Source #

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

PGType "bpchar" Source # 

Associated Types

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

Methods

pgTypeName :: PGTypeID "bpchar" -> PGName Source #

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

PGType "bytea" Source # 

Associated Types

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

PGType "character varying" Source # 

Associated Types

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

Methods

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

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

PGType "date" Source # 

Associated Types

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

PGType "double precision" Source # 

Associated Types

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

Methods

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

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

PGType "integer" Source # 

Associated Types

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

Methods

pgTypeName :: PGTypeID "integer" -> PGName Source #

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

PGType "interval" Source # 

Associated Types

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

Methods

pgTypeName :: PGTypeID "interval" -> PGName Source #

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

PGType "json" Source # 

Associated Types

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

PGType "jsonb" Source # 

Associated Types

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

PGType "name" Source # 

Associated Types

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

PGType "numeric" Source # 

Associated Types

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

Methods

pgTypeName :: PGTypeID "numeric" -> PGName Source #

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

PGType "oid" Source # 

Associated Types

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

PGType "real" Source # 

Associated Types

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

PGType "record" Source # 

Associated Types

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

Methods

pgTypeName :: PGTypeID "record" -> PGName Source #

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

PGType "smallint" Source # 

Associated Types

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

Methods

pgTypeName :: PGTypeID "smallint" -> PGName Source #

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

PGType "text" Source # 

Associated Types

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

PGType "time with time zone" Source # 

Associated Types

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

Methods

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

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

PGType "time without time zone" Source # 

Associated Types

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

Methods

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

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

PGType "timestamp with time zone" Source # 

Associated Types

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

Methods

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

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

PGType "timestamp without time zone" Source # 

Associated Types

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

Methods

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

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

PGType "uuid" Source # 

Associated Types

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

PGType "void" Source # 

Associated Types

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

class PGType t => PGParameter t a where Source #

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 Source #

Encode a value to a PostgreSQL text representation.

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

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 Source #

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

Instances

PGRecordType t => PGParameter t PGRecord Source # 
PGStringType t => PGParameter t Text Source # 
PGStringType t => PGParameter t Text Source # 
PGStringType t => PGParameter t ByteString Source # 
PGStringType t => PGParameter t PGName Source # 
PGStringType t => PGParameter t ByteString Source # 
PGStringType t => PGParameter t String Source # 
PGParameter "\"char\"" Char Source # 

Methods

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

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

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

PGParameter "\"char\"" Word8 Source # 

Methods

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

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

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

PGParameter "any" PGValue Source # 

Methods

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

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

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

PGParameter "bigint" Int64 Source # 

Methods

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

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

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

PGParameter "boolean" Bool Source # 

Methods

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

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

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

PGParameter "bytea" ByteString Source # 

Methods

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

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

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

PGParameter "bytea" ByteString Source # 

Methods

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

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

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

PGParameter "cidr" PGInet Source # 

Methods

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

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

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

PGParameter "date" Day Source # 

Methods

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

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

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

PGParameter "double precision" Double Source # 

Methods

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

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

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

PGParameter "double precision" Float Source # 

Methods

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

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

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

PGParameter "inet" PGInet Source # 

Methods

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

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

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

PGParameter "integer" Int32 Source # 

Methods

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

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

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

PGParameter "interval" DiffTime Source # 

Methods

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

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

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

PGParameter "json" Value Source # 

Methods

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

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

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

PGParameter "jsonb" Value Source # 

Methods

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

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

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

PGParameter "numeric" Rational Source # 

Methods

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

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

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

PGParameter "numeric" Scientific Source # 

Methods

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

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

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

PGParameter "oid" OID Source # 

Methods

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

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

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

PGParameter "real" Float Source # 

Methods

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

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

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

PGParameter "smallint" Int16 Source # 

Methods

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

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

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

PGParameter "time without time zone" TimeOfDay Source # 

Methods

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

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

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

PGParameter "timestamp with time zone" UTCTime Source # 

Methods

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

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

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

PGParameter "timestamp without time zone" LocalTime Source # 

Methods

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

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

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

PGParameter "uuid" UUID Source # 

Methods

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

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

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

PGParameter "void" () Source # 

Methods

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

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

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

PGParameter t a => PGParameter t (Maybe a) Source # 
(PGRangeType t, PGParameter (PGSubType t) a) => PGParameter t (Range a) Source # 
PGParameter "time with time zone" (TimeOfDay, TimeZone) Source # 

Methods

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

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

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

class PGType t => PGColumn t a where Source #

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 Source #

Decode the PostgreSQL text representation into a value.

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

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

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

Instances

PGRecordType t => PGColumn t PGRecord Source # 

Methods

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

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

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

PGStringType t => PGColumn t Text Source # 

Methods

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

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

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

PGStringType t => PGColumn t Text Source # 

Methods

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

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

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

PGStringType t => PGColumn t ByteString Source # 
PGStringType t => PGColumn t PGName Source # 

Methods

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

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

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

PGStringType t => PGColumn t ByteString Source # 
PGStringType t => PGColumn t String Source # 

Methods

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

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

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

PGType t => PGColumn t PGValue Source # 

Methods

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

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

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

PGColumn "\"char\"" Char Source # 

Methods

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

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

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

PGColumn "\"char\"" Word8 Source # 

Methods

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

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

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

PGColumn "bigint" Int64 Source # 

Methods

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

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

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

PGColumn "boolean" Bool Source # 

Methods

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

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

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

PGColumn "bytea" ByteString Source # 

Methods

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

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

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

PGColumn "bytea" ByteString Source # 

Methods

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

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

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

PGColumn "cidr" PGInet Source # 

Methods

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

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

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

PGColumn "date" Day Source # 

Methods

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

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

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

PGColumn "double precision" Double Source # 

Methods

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

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

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

PGColumn "inet" PGInet Source # 

Methods

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

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

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

PGColumn "integer" Int32 Source # 

Methods

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

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

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

PGColumn "interval" DiffTime Source #

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 Source #

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

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

PGColumn "json" Value Source # 

Methods

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

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

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

PGColumn "jsonb" Value Source # 

Methods

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

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

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

PGColumn "numeric" Rational Source #

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 Source #

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

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

PGColumn "numeric" Scientific Source # 

Methods

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

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

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

PGColumn "oid" OID Source # 

Methods

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

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

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

PGColumn "real" Double Source # 

Methods

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

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

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

PGColumn "real" Float Source # 

Methods

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

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

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

PGColumn "smallint" Int16 Source # 

Methods

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

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

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

PGColumn "time without time zone" TimeOfDay Source # 

Methods

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

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

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

PGColumn "timestamp with time zone" UTCTime Source # 

Methods

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

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

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

PGColumn "timestamp without time zone" LocalTime Source # 

Methods

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

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

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

PGColumn "uuid" UUID Source # 

Methods

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

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

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

PGColumn "void" () Source # 

Methods

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

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

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

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

Methods

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

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

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

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

Methods

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

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

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

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

Methods

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

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

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

class PGType t => PGStringType t Source #

Instances

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

class PGType t => PGRecordType t Source #

Instances

PGRecordType "record" Source #

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 Source #

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

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

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 Source #

Final column decoding function used for a nullable result value.

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

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

Conversion utilities

pgQuote :: ByteString -> ByteString Source #

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

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

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) Source #

Parse double-quoted values ala pgDQuote.