[Dbix-class] InflateColumn DateTime tricks with MSSQL/Microsoft_SQL_Server

Matt Lawrence matt.lawrence at ymogen.net
Tue Jan 15 16:58:03 GMT 2008


Michael Higgins wrote:
> The error I was getting is: Invalid date format: 2008-01-14 00:00:00.000
>
> So, maybe this should be: return $type->new( pattern => '%m/%d/%Y
> %H:%M:%S.%N' ); ???
>   
You should be able to set this by doing:

    $schema->storage->datetime_parser->pattern('%m/%d/%Y %H:%M:%S.%3N');

this will obviously only work if the datetime parser is really a
DateTime::Format::Strptime object.

> I've added the sub as above, with the nanosecond string,
> to ::DBI::ODBC::Microsoft_SQL_Server.pm and set it explicitly in my
> script.
>
> My classes look like => {accessor=>'order_date',data_type =>
> 'datetime'},
>
> If I set the storage type in my script, then call ->ensure_connected,
> it deletes the key I set:
>   
What happens if you call ensure_connected first? The storage type is
normally determined when the connection is first made, so it figures
that it is overwritten if you set it before connecting.


Matt




More information about the DBIx-Class mailing list