Hello Peter,
Your problem sounds entirely valid... however, I do not see a straightforward way to make the DAO classes support this in a 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.
Let me know what you think.
Marijn
On Feb 10, 2008 7:28 PM, Peter Eddy peter.eddy@gmail.com wrote:
Hi, new postmodern user here.
I'd like to be able to use postgresql's 'default' column value feature instead of an :initform in deftable. Is that possible? I haven't had any luck getting it to work.
I have a couple of reasons for wanting to do this, first I have several tables that get their primary keys from a single postgresql sequence, e.g.:
create table fooA ( id int8 default nextval( 'id_source' ) primary key, ... )
create table fooB ( id int8 default nextval( 'id_source' ) primary key, ... )
Additionally, other table columns use the 'default' option to create creation time stamps and so forth.
I can't remove these options from the table definitions because that would break the other applications that use the database.
So, what I'm really after is the ability to define fields with deftable so that those fields are not initialized by (make-instance) but read into the dao after creation, similarly to how auto-id appears to work.
I looked through the archives but didn't see anything that looked related to this.
thanks, Peter _______________________________________________ postmodern-devel mailing list postmodern-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel