[postmodern-devel] single-key object magic

Marijn Haverbeke marijnh at gmail.com
Wed May 9 18:30:29 UTC 2012


Hello Greg,

I'm hesitant to incorporate any 'magic' like this into the core
library. It's a matter of aesthetics, but I'm no big fan of this kind
of do-what-I-mean API style. I prefer explicitness. If you want to
work on a library that does a lot of helpful things under the covers,
I think that's best tackled as a layer on top of Postmodern, so that
people who want a different approach, or just the basics, don't have
to deal with it.

Best,
Marijn

On Wed, May 9, 2012 at 7:27 PM, Greg Pfeil <greg at technomadic.org> wrote:
> 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?
>
>
> _______________________________________________
> postmodern-devel mailing list
> postmodern-devel at common-lisp.net
> http://lists.common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel
>




More information about the postmodern-devel mailing list