Next: Miscellaneous OMM, Previous: Builtin Converters, Up: Octet Molding/Mashing [Contents][Index]
To define a new non-array type means associating with the type name a
procedure for converting from a PostgreSQL string representation to a Scheme
object (the objectifier), a procedure to do the conversion in the
opposite direction (the stringifier), and a default string to use if
none is specified (for example, during an INSERT
operation). For this,
use the define-db-col-type
procedure.
Register type name with default, stringifier and
objectifier procs. name is a symbol. default is a
string to use if the Scheme object is #f
. stringifier is a
proc that takes a Scheme object and returns a string suitable for use in an
INSERT VALUES
SQL command. objectifier is a proc that takes a
string and returns the Scheme object parsed out of it.
Both stringifier and objectifier need not worry about SQL-style quoting (using single quotes) and related quote escaping.
If name already exists, it is redefined.
See also type-registered?
.
To express conversion of arrays (no matter the dimensionality) of non-array
types, use the register-array-variant
procedure.
Register an array type of rank dimensions based on simple.
rank is a (typically small) positive integer.
simple is a type name already
registered using define-db-col-type
.
By default, the associated stringifier and objectifier are
those of simple. If stringifier and objectifier
are specified and non-#f
, Guile-PG uses them instead.
The default value of all array types is ‘{}’ and cannot be changed.
Return the name (a symbol) of the array type. This is basically
rank asterisks followed immediately by simple. For example,
if rank is 2 and and simple is int4
, the name would
be **int4
.
Next: Miscellaneous OMM, Previous: Builtin Converters, Up: Octet Molding/Mashing [Contents][Index]