Next: , Up: Octet Molding/Mashing   [Contents][Index]


10.1 Consulting Existing Converters

To see if a type is “known” to Guile-PG, use the type-registered? procedure. Use type-foo procs for particulars.

Procedure: type-registered? type

Return #t if type (a symbol) has registered converters.

Define: type-stringifier type

Return the stringifier for type (a symbol).

Define: type-objectifier type

Return the objectifier for type (a symbol).

Define: type-default type

Return the default for type (a symbol).

Procedure: type-sql-name type

Return the SQL name (a string) of type (a symbol).

example

Here is a simple example that uses type-objectifier to convert a two-dimensional text array value into a nested list:

(let ((raw (pg-getvalue result 0 0))
      (conv (type-objectifier '**text)))
  (format #t "~A~%~S~%" raw (conv raw)))

-| {{a,b},{c,d}}
-| (("a" "b") ("c" "d"))

Note that even though the type is an “array”, as implied by the leading asterisks, 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.