[Dbix-class] how to search by date?
Michael Higgins
linux at evolone.org
Tue Jan 15 05:38:53 GMT 2008
On Mon, 14 Jan 2008 19:42:50 -0800
Michael Higgins <linux at evolone.org> wrote:
> On Tue, 15 Jan 2008 00:23:23 +0100
> Tobias Kremer <list at funkreich.de> wrote:
>
> > Am 15.01.2008 um 00:13 schrieb Michael Higgins:
> > > Shouldn't this datetime cast/conversion thing be automagical?
> > >
> > > eval { $rs = $schema->resultset('DB::DATA')->search(
> > > {Name => {'like', $name_like},
> > > "the date" => \"= cast ('01/4/2008' as
> > > datetime)" })};
> > >
> > > I just can't figure out, I'm sure, where the syntax is documented
> > > for searching by datetime-type of column data via DBIx::Class.
> >
> >
> > Use DateTime and the following DBIC component for automatic
> > inflating/ deflating to/from your database:
> >
> > http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/InflateColumn/DateTime.pm
> >
>
> Thanks, Tobias.
>
> However,
>
> DBIx::Class::InflateColumn::get_inflated_column(): Couldn't load
> DateTime::Format::MySQL: Can't locate DateTime/Format/MySQL.pm
>
> [ CPAN ]
>
> Then,
>
> Invalid date format: 2008-01-14 00:00:00.000
> at /usr/lib/perl5/vendor_perl/5.8.8/DBIx/Class/InflateColumn/DateTime.pm
> line 76
>
> It works on the setup side, in my query (for whatever reason it
> returns today's orders), but I can't make ->mdy() call on my return
> row... :0-(
>
> Any thoughts? Does this need a DateTime/Format/MSSQL.pm module, or
> something? That seems doable, but if that's the case, wouldn't
> DBIx-Class/lib/DBIx/Class/InflateColumn/DateTime.pm need to be changed
> quite a bit? (I can't make heads or tails of how this calls MySQL.pm.)
>
> So, IOW, I'm up the creek with no paddle over MSSQL-specific stuff yet
> again?
>
> Any thoughts appreciated. ;-)
>
Reply to myself here. From the docs: "This module figures out the type
of DateTime::Format::* class to inflate/deflate with based on the type
of DBIx::Class::Storage::DBI::*"
Seems I'm using '::DBI'. Hmm.
DBIx::Class::Storage::DBI::MSSQL exists. It sez:
$schema->storage_type('::DBI::MSSQL');
Okay. Now maybe I have the right storage being reported. What would be
the next step? Should this just work, or wouldn't it now call for a
module that doesn't exist?
Well, no, it doesn't try to get MSSQL syntax, it just dies like before:
Invalid date format: 2008-01-14 00:00:00.000
What needs to happen to make this work, or am I just confused?
Cheers,
--
|\ /| | | ~ ~
| \/ | |---| `|` ?
| |ichael | |iggins \^ /
michael.higgins[at]evolone[dot]org
More information about the DBIx-Class
mailing list