[Dbix-class] set_on_create problem

Peter Rabbitson rabbit+dbic at rabbit.us
Thu Apr 26 06:43:56 GMT 2012


Steve wrote:
> Hello,
> 
> I have set up a user table both 'updatedon' and 'createdon' fields.  
> They are of type Datetime (MySQL).  My entire schema was autogenerated 
> by DBIC::Loader script with the 'components=TimeStamp' directive.  I 
> have confirmed that the resultset loads the "InflateColumn::DateTime" 
> component, and included the:
> 
> __PACKAGE__->add_columns( 'createdon',{ %{ 
> __PACKAGE__->column_info('createdon') }, set_on_create => 1, } );
> 
> directive.  If I understand this correctly...  any time I create a new 
> user, this field should be populated with the current (system) time, but 
> it is not.
> 
> I am using HTML::FormHandler, and so have gotten 'around' this (bit of a 
> pun here in case you missed it) with a moose method modifier.  This is a 
> kludge, and I would like to fix it by having DBIx::Class take care of it 
> for me.
> 
> Can anyone tell me what I'm missing, or if more info is needed?
> 

You are missing https://metacpan.org/module/DBIx::Class::TimeStamp

Cheers



More information about the DBIx-Class mailing list