[CDBI] Re: Deep recursion

Edward J. Sabol sabol at alderaan.gsfc.nasa.gov
Wed Aug 8 21:53:02 BST 2007


Dave Howorth asked:
> Are you saying that there's a problem with naming a column 'id' [...]?

There shouldn't be. Maybe there was at some point in the history of
Class::DBI and that's what Schwern is remembering, but the latest code checks
to see if the column name is 'id' and appears to do the right thing when
creating the accessors. If it doesn't, someone should file a bug report.


Arshavir Grigorian wrote:
>> The reason I need access to the primary key is that I have the
>> following sql to set the sysdate (from the wiki site):
>>
>> __PACKAGE__->set_sql(set_sysdate => qq{
>>   UPDATE __TABLE__
>>      SET %s = now()
>>    WHERE __IDENTIFIER__
>> });
>>
>> and to execute this I have to do:
>>
>> $obj->sql_set_sysdate("some_dt")->execute($obj->id);
[..]
>> Also, I noticed that this problem occurs only on objects that have
>> just been created/inserted (vs objects that one gets through a
>> retrieve/search operation).
>>
>> $obj = TAB->retrieve(...); $obj->id; - works fine.

I think the fact that your primary key is named "id" is a red herring.
Are you using a 'before_create' trigger to set the date? It sure sounds like
it. If so, Dan Rowles posted a workaround to this mailing list on 12 Jan
2006. If not, you might want to look at that thread anyway.

Hope this helps,
Ed



More information about the ClassDBI mailing list