To see what type converters are already defined, use the dbcoltypes
procedure. To get a type-converter object that encapsulates
the stringifier, the objectifier and the default, use
the procedure
dbcoltype-lookup
. The components of the returned object can be read
using the dbcoltype:FOO
procedures.
Return a type-converter object given its type-name, a symbol. Return
#f
if no such t-c object by that name exists.
Here is a simple example that uses dbcoltype-lookup
and
dbcoltype:objectifier
to convert a text[][]
value
into a nested list:
(let ((raw (pg-getvalue result 0 0)) (conv (dbcoltype:objectifier (dbcoltype-lookup 'text[][])))) (format #t "~A\n~A\n" raw (conv raw))) -| {{a,b},{c,d}} -| (("a" "b") ("c" "d"))
Note that even though the type is an "array", as implied by the square brackets, the result is a list. This is mostly due to a limitation in PostgreSQL: dimensionality is not stored for array types, so the conversion cannot be done in a random-access manner. Perhaps this will change in the future.
Here is the set of builtin converters and their default values.
smallint "0" integer "0" bigint "0" int "0" int2 "0" int4 "0" int8 "0" numeric "0" decimal "0" real "0.0" double "0.0" float4 "0.0" float8 "0.0" serial "0" bigserial "0" serial4 "0" serial8 "0" varchar #f character #f char "?" text "" name "???" bytea #f timestamp "1970-01-01 00:00:00" boolean "f" bool "f" inet "0.0.0.0" cidr "0.0.0.0" inet-host "127.0.0.1" macaddr "00:00:00:00:00:00" oid "-1" aclitem "?"