[postmodern-devel] single-key object magic

Greg Pfeil greg at technomadic.org
Wed May 9 17:27:36 UTC 2012


I've made a few changes to Postmodern. They both try to do a little magic in the case where a table has a single primary key column. The first change allows you to use a DAO-OBJECT directly as a parameter, rather than pulling out the key field. EG:

> (select-dao 'foo (:= 'bar bar))

instead of having to do

> (select-dao 'foo (:= 'bar (id bar)))

And the second allows the use of a DAO-CLASS name in the :COL-TYPE field of a slot definition. EG:

> (defclass bar () ((id :col-type serial)) (:metaclass dao-class))
> (defclass foo () ((bar :col-type (or db-null bar))) (:metaclass dao-class))

instead of

> (defclass bar () ((id :col-type serial)) (:metaclass dao-class))

> (defclass foo () ((bar :col-type (or db-null integer))) (:metaclass dao-class))


These both seem pretty basic, but they mean that you can change the primary key column name or type without having to make changes throughout your code. Also, I see it as a first step toward being able to (eagerly or lazily) auto-populate slots with full objects rather than keys.

Does this seem useful, too magical, or already there but I missed it?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: single-key.patch
Type: application/octet-stream
Size: 2432 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/postmodern-devel/attachments/20120509/2927b555/attachment.obj>


More information about the postmodern-devel mailing list