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


11.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.

Procedure: type-stringifier type

Return the stringifier for type (a symbol).

Procedure: type-objectifier type

Return the objectifier for type (a symbol).

Procedure: 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.

obsolete interface

NB: The rest of this section describes an obsolete interface.

To get a 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.

Procedure: dbcoltypes

NB: This procedure will be removed by 2015-12-31.

Return names of all registered converters.

Procedure: dbcoltype-lookup type-name

NB: This procedure will be removed by 2015-12-31.

Return a converter object given its type-name, a symbol. Return #f if no such object by that name exists.

Procedure: dbcoltype:stringifier tc

NB: This procedure will be removed by 2015-12-31.

Extract stringifier from the converter object tc.

Procedure: dbcoltype:objectifier tc

NB: This procedure will be removed by 2015-12-31.

Extract objectifier from the converter object tc.

Procedure: dbcoltype:default tc

NB: This procedure will be removed by 2015-12-31.

Extract default string from the converter object tc.


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