[Dbix-class] InflateColumn DateTime tricks with
MSSQL/Microsoft_SQL_Server
Michael Higgins
linux at evolone.org
Tue Jan 15 17:35:17 GMT 2008
On Tue, 15 Jan 2008 09:01:49 -0800
Marc Mims <marc at questright.com> wrote:
[snip]
>
> I think Michael is using
> DBIx::Class::Storage::ODBC::Microsoft_SQL_Server, which doesn't
> provide build_datetime_parser---yet. I need to add that. Actually,
> DBI::MSSQL and DBI::ODBC::Microsoft_SQL_Server need to be unified,
> but I hesitate to do that without assistance from someone actually
> using DBI::MSSQL so we can ensure the unified code works on both the
> DBD::ODBC and DBD::Sybase layers.
>
> Micheal, make a local copy of Microsoft_SQL_Server and copy the
> build_date_time_parser method from DBI::MSSQL into it. If that works
> as expected, then I'll add it Microsoft_SQL_Server and commit it.
Added 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.%3N' );
}
I did that, basically, as it seemed to be the thing to do.
The error is:
Can't call method "mdy" on an undefined value
What I don't get is where InflateColumn::DateTime chooses which flavor
of SQL to honor.
>
> However, inflation/deflation may not be the whole problem, here. If I
> read your original message correctly, you were trying to use a
> DateTime object in a search. There is no inflate/deflate done,
> there. It's just stringification.
No, the search is fine using a string. What happens is the record is
returned, but accessing the data fails.
>
> If you have a valid DateTime object at that point, then $dt->mdy('/')
> should do what you expect.
I know. It doesn't.
Can anyone figure out how InflateColumn::DateTime gets the storage
engine string to pick the right syntax? I put this in my loop, to be
sure it hadn't been changed:
print $schema->storage_type;
::DBI::ODBC::Microsoft_SQL_Server
::DBI::ODBC::Microsoft_SQL_Server
::DBI::ODBC::Microsoft_SQL_Server
::DBI::ODBC::Microsoft_SQL_Server
::DBI::ODBC::Microsoft_SQL_Server
::DBI::ODBC::Microsoft_SQL_Server
::DBI::ODBC::Microsoft_SQL_Server
::DBI::ODBC::Microsoft_SQL_Server
::DBI::ODBC::Microsoft_SQL_Server
PK: 155392
Can't call method "mdy" on an undefined value
On the first record it attempts to pull and print.
--
|\ /| | | ~ ~
| \/ | |---| `|` ?
| |ichael | |iggins \^ /
michael.higgins[at]evolone[dot]org
More information about the DBIx-Class
mailing list