[Dbix-class] Re: A timestamp field is null when a record is created

Eugene Yarmash e.yarmash at gmail.com
Wed Oct 31 13:44:54 GMT 2012


On 10/31/2012 03:00 PM, dbix-class-request at lists.scsys.co.uk wrote:

>> On Tue, Oct 30, 2012 at 01:54:38PM +0100, Alexander Hartmaier wrote:
>>> $obj->discard_changes;
>>> because the database assigns the column value on insert but DBIC doesn't
>>> fetch it from he db.
>> Please do not use/recommend discard_changes() for this use-case. d_s()
>> is too heavy as it refetches *everything* from the database. What the OP
>> wants to achieve is done by using the colinfo flag retrieve_on_insert[1]
> I wasn't sure if that already exists, great!
> I always recommend to assign default values in the model and don't rely
> on the database, DBIx::Class::TimeStamp with set_on_create in that case.
"discard_changes" is more general approach. For example it can be used 
with "prefetch".


-- 
Regards,
Eugene Yarmash




More information about the DBIx-Class mailing list