[postmodern-devel] Point type

Marijn Haverbeke marijnh at gmail.com
Sun Jan 2 13:17:13 UTC 2011


Hi Slobodan,

To make this kind of thing less awkward, your best bet is to define a
reader and a writer for the type. You can find the details in the
reference guide [1], but in short, you'd:

- Find a Lisp type you want to use for values of this type. In this
case, I think (defstruct point x y) is a good candidate.
- Figure out the OID of the point type -- I usually do this by adding
(print type-id) somewhere in read-field-descriptions, and then
querying a row that contains the type I'm interested in. Maybe there
are better ways.
- Use cl-postgres:set-sql-reader to associate this OID with a reader
function that converts the string (or, if you want to be
super-efficient, binary) representation of the type to a lisp value.
- Specialize cl-postgres:to-sql-string on the point struct type, and
have it output the Postgres-compatible string representation.

Let me know if you run into trouble.

Best,
Marijn




More information about the postmodern-devel mailing list