[Dbix-class] DateTime independant from the database

Byron Young Byron.Young at riverbed.com
Thu May 22 00:30:01 BST 2008


Hey Antoine.

hallouina-dbix at yahoo.fr wrote on 2008-05-21:
> Hi everybody,
>
> I'm new and happy to use DBIx.
>
> I'm creating a little Catalyst application. I have a forms and use
> FormFu to create it. I full it almost completly and need to complete 2
> others date field int the controller. I have created a sql file then

Can you explain what you're trying to do a little better?  Do you need another datetime field in your model, or are you combining two fields with some date math and storing that in your current datecreation field?


> generate my schema. I never modified my schema in catalyst. I want to
> keep a model that stay database independant. So I want to used
> DBIx::Class::InflateColumns::DateTime (as Jess Robinson advise me on
> irc). But the documentation about this module is not very expensive.
>
> On my Project.pm I have this warning :
>
> # Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-05-01 01:36:27
> # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:tS5sQsszV7IB1uRDv4CfdA
>
>
> So I try to add __PACKAGE__->load_components('InflateColumn::DateTime');
>  at the end of Project.pm . And as the documentation say, to add a date
> I should do something like :
>
>
> __PACKAGE__->add_columns(
>     datecreation => { data_type => 'datetime' }
>   );
>
> But the field "datecreation" already exist and as say the warning,
> I sould not modify anything above.
>

Looks like DBIx::Class::Schema::Loader already added the datecreation field, so you don't need to add it again.


> So how could I do to solve my problem please ? I just want to add 2
> dates before saving my form.
>

What's the problem exactly?  If you need to add a column to your table, I would suggest updating the table and regenerating your schema using DBIx::Class::Schema::Loader.  You could add new columns by hand, but I don't think mixing the two approaches is a good idea.

Byron




More information about the DBIx-Class mailing list