[Dbix-class] DateTime independant from the database

Matt S Trout dbix-class at trout.me.uk
Thu May 29 11:44:48 BST 2008


On Wed, May 21, 2008 at 10:21:29PM +0000, hallouina-dbix at yahoo.fr wrote:
> 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 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.

Schema::Loader should already have filled out the type as 'datetime'.

You just need to get InflateColumn::DateTime loaded -before- the
Schema::Loader generated add_columsn. There's an option to Schema::Loader
to do this; I suggest you read through the perldocs for

DBIx::Class::Schema::Loader
DBIx::Class::Schema::Loader::Base

before using it further. Complaining about documentation when you clearly
haven't read most of it doesn't help.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the DBIx-Class mailing list