Michael Higgins wrote:
Folks --What I thought would be trivial turns to be burdensome. Probably, it's just me, but: I've done my best to understand what DBIx-Class/lib/DBIx/Class/InflateColumn/DateTime.pm does, yet I can't see how it honors the reported storage engine. But, if it does, I've tried setting the storage engine to ::DBI::MSSQL with no joy. There is a new module, ::DBI::ODBC::Microsoft_SQL_Server.pm which provides, if I understand it, some overloaded methods to accommodate. And, examining ::DBI::MSSQL, I see this: sub build_datetime_parser { my $self = shift; my $type = "DateTime::Format::Strptime"; eval "use ${type}"; $self->throw_exception("Couldn't load ${type}: $@") if $@; return $type->new( pattern => '%m/%d/%Y %H:%M:%S' ); } And in InflateColumn::DateTime: "This module figures out the type of DateTime::Format::* class to inflate/deflate with based on the type of DBIx::Class::Storage::DBI::*" So what am I missing? Why isn't my storage already determined when I start my script? Why doesn't setting it explicitly to this module, with this subroutine produce a proper parser..?? Is it possible that this ::DBI::MSSQL sub is honored, but not properly coded? * %N Nanoseconds. For other sub-second values use "%[number]N". 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' ); ??? 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: $trex_schema->storage_type('::DBI::ODBC::Microsoft_SQL_Server'); # $trex_schema->storage->ensure_connected();print $trex_schema->storage_type; # overwritten to ::DBI using line aboveAt any rate, nothing breaks in getting the records, the selects are still working (for whatever reason) but now the call to ->mdy('/') fails:Can't call method "mdy" on an undefined valueand a call without ->mdy returns undef. Can anyone help figure this out? It seems like it should work as advertised without my intervening, but didn't. I've done my best to try to root out the problem, and failed.Any help appreciated.
I'm late to the party, but I use this component a lot.First, is DateTime::Format::MySQL actually installed? (did this thread start about MySQL?)
Second, InflateColumn::DateTime inflates db column values into DateTime objects. Keep this in mind though, that when you set values using accessors:
$obj->dtfield(DateTime->new)
When setting as an object, no need to worry. It should DoTheRightThing...
$obj->dtfield($string)
When setting as a string, you must supply the string in the same format
as the database you are using, and MySQL, or really SQLite will take
just about any thing because it's silly, but the MySQL formatter may not
understand it.
Now, first things second: show us the source of your schema classes, where you load this component and declate fields as a datetime type.
-=Chris
signature.asc
Description: OpenPGP digital signature
_______________________________________________ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED]
