[Dbix-class] Pointless update on a date field

Richard Jones ra.jones at dpw.clara.co.uk
Thu Sep 13 20:01:25 GMT 2007


Jonathan Rockway wrote:
> Richard Jones wrote:
>> There is obviously something amiss because if I omit my own
>> date_to_mysql() method then system tries to retrieve dates in
>> dd/mm/yyyy format. 
> 
> I think you're misunderstanding InflateColumn::DateTime.  

Well you're not wrong there.

Here's some
> example code:
> 
>   $some_rs->create({ creation_time => DateTime->now });

But I still don't see how to translate that to my example. Do I need to 
setup __PACKAGE__->inflate_columns() in Schema::Foo as in the docs? I 
assumed so and did so, using DateTime::Format::MySQL->parse_datetime() 
for inflation and D::F::M::format_datetime() for deflation.

How then do I do something like $schema->update( \%form_data ) when the 
user submits a date formatted as '20/12/2000'. How would you do it with 
the US equivalent '12/20/2000'?

Actually I think I'm partly there as the dumped sql now shows a definite 
conversion to MySQL format, at least for some dates (others are 
generating Template::Context errors).

Perhaps you could just confirm I'm on the right track with just defining 
the inflate_columns inflate and deflate subs, and letting the db do the 
rest? Thanks.
-- 
Richard Jones



More information about the DBIx-Class mailing list