Next: Selected Notes About Some Types, Up: Types Conversion
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.
[NOTE: docs missing for dbcoltypes]
[NOTE: docs missing for dbcoltype-lookup]
[NOTE: docs missing for dbcoltype:stringifier]
[NOTE: docs missing for dbcoltype:objectifier]
[NOTE: docs missing for dbcoltype:default]
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.