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.