[postmodern-devel] Using postgresql's default option for column values

Marijn Haverbeke marijnh at gmail.com
Mon Feb 11 22:11:49 UTC 2008


Hey Peter,

Attached is a patch that will make it possible to pass a
(:skip-unbound t) option to defclass, which will make the insert-dao
method for that class check for unbound slots when it inserts a new
record. You'll have to pull the repository and apply it with 'darcs
apply' if you want to use it. I'm rather doubting whether I want to
include it in the main repository -- defclass is already an
extravaganza of crazy macroism as it is, and this change is just a
piece of duct tape around the general issues that it has. I'm hoping
to simplify and generalise some of its functionality with a metaclass
and some MOP magic, but I haven't gotten around to that yet.

So consider this patch a temporary solution. Drew's trick also looks
nice, only it introduces even more queries at object-creation time. I
will probably end up adding :sql-default slot options to defclass,
which act like :initforms, but contain s-sql expressions instead. That
way, table creation can add the proper defaults to the fields, and the
object initializer can pull in all the default values in one go.

Regards,
Marijn


On Feb 11, 2008 12:47 AM, Peter Eddy <peter.eddy at gmail.com> wrote:
> Hi Marijn,
>
> I think an option to not try to save unbound slots would solve my
> problem perfectly. In the mean time I'll use your :initform query
> suggestion. We have a very 'involved' DBA on this project and I'm not
> sure that this double-querying will be acceptable to her in the long
> run, but it'll certainly be fine for the development DB. So, no great
> urgency.
>
> Thanks very much!
>
> - Peter
>
> On Feb 10, 2008 2:04 PM, Marijn Haverbeke <marijnh at gmail.com> wrote:
> > particularly elegant way. In some cases, you can just give the fields
> > an :initform like (query (:select (:nextval 'my-sequence))). This has
> > the disadvantage of generating extra queries whenever you create a dao
> > object. If you think it would be useful, I can add some exception to
> > the save-dao code to make sure it does not try to save slots that are
> > unbound -- that way you could just not  initialise the fields that
> > have default values, and wait until insert time for them to get a
> > value. Of course, if you need access to these values before saving the
> > record, this will not help.
>
> _______________________________________________
> postmodern-devel mailing list
> postmodern-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: skip-unbound.patch
Type: text/x-diff
Size: 8993 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/postmodern-devel/attachments/20080211/abdb9dfd/attachment.patch>


More information about the postmodern-devel mailing list