[Dbix-class] possible bug in DBIC:ResultSet?
Jess Robinson
castaway at desert-island.demon.co.uk
Thu Jun 8 09:22:27 CEST 2006
On Wed, 7 Jun 2006, Mark Hedges wrote:
>
>> On Tue, 6 Jun 2006, Mark Hedges wrote:
>>> I didn't look closely. This is another entity that has a
>>> timestamp DEFAULT CURRENT_TIMESTAMP() as a column of an MCPK.
>>>
>>> I tried adding
>>>
>>> __PACKAGE__->load_components(qw( PK::Auto Core ));
>>>
>>> to the class package for this entity. It doesn't help. Same error.
>>>
>>> Probably because last_insert_id() is looking for an
>>> auto-increment value and doesn't know anything about timestamps.
>>>
>>> I'm going to fake this one using a DateTime->now from the
>>> script instead of trying to use the MySQL server's NOW().
>
> On Wed, 7 Jun 2006, Jess Robinson wrote:
>>
>> Umm, not sure I understand the restated problem, but if your DB is
>> auto-filling fields and you want to retrieve them into your row object,
>> you want to either:
>> write your own component thath overloads insert, just like PK::Auto does,
>> for those fields
>> or:
>> Call ->discard_changes on your object, after inserting it, which will
>> update it with values in the DB.
>
>
> The problem is that the auto-filled timestamp field is part of the MCPK.
> PK's for a support ticket system are originator e-mail, subject and timestamp.
>
Ah, I wondered what that strange acronym meant.. Yeah, using timestamps
for that is a bad idea (not that one necessarily always has a choice), I
suspect if it was a single field PK, you might have had a chance.. (Not
that I've tried it with last_indert_id .. You might get better answers
from the DBI list itself, this not really being a DBIC problem.
Or just use your solution ;)
Jess
More information about the Dbix-class
mailing list