templatepg-0.2.3: A PostgreSQL access library with compile-time SQL type inference

Safe HaskellNone

Database.TemplatePG.Types

Description

All type conversion to and from the PostgreSQL server is handled here.

Synopsis

Documentation

data PGType Source

TemplatePG currenly only supports a handful of types. It also doesn't distinguish between numeric types with different ranges. More types are the most likely feature of future TemplatePG releases.

Constructors

PGBoolean

bool

PGInteger

integer

PGReal

float

PGText

text/varchar

PGTimestampTZ

timestamptz (timestamp with time zone)

PGDate

date (day without time)

PGInterval

interval (a time interval), send-only

Instances

pgTypeFromOIDSource

Arguments

:: Int

PostgreSQL type OID

-> PGType 

Convert a type OID from PostgreSQL's catalog to a TemplatePG representation. To get a list of types: SELECT typname, oid FROM pg_type Note that I have assumed, but not tested, that type OIDs for these basic types are consistent across installations. If not, I'm going to have to switch to using the text descriptions

pgStringToType :: PGType -> Q ExpSource

Convert a string from PostgreSQL of the given type into an appropriate Haskell value. Or, more accurately, given a PostgreSQL type, create a function for converting a string of that type into a compatible Haskell value. pgStringToType :: PGType -> (String -> ?)

pgTypeToString :: PGType -> Q ExpSource

Convert a Haskell value to a string of the given PostgreSQL type. Or, more accurately, given a PostgreSQL type, create a function for converting compatible Haskell values into a string of that type. pgTypeToString :: PGType -> (? -> String)