[postmodern-devel] Using postgresql's default option for column values
Peter Eddy
peter.eddy at gmail.com
Tue Feb 12 01:11:44 UTC 2008
Thank you Marijn and Drew, very much appreciated!
2008/2/11 Marijn Haverbeke <marijnh at gmail.com>:
> 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
> >
>
> _______________________________________________
> postmodern-devel mailing list
> postmodern-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel
>
>
More information about the postmodern-devel
mailing list