Safe Haskell | None |
---|
All type conversion to and from the PostgreSQL server is handled here.
- data PGType
- = PGBoolean
- | PGInteger
- | PGReal
- | PGText
- | PGTimestampTZ
- | PGDate
- | PGInterval
- pgTypeFromOID :: Int -> PGType
- pgStringToType :: PGType -> Q Exp
- pgTypeToString :: PGType -> Q Exp
Documentation
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.
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 |
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)