[Dbix-class] Re: DateTime objects passed to search() are not supported properly

Peter Rabbitson rabbit+dbic at rabbit.us
Wed Sep 19 10:36:41 GMT 2012


On Wed, Aug 15, 2012 at 09:24:31AM -0700, Bill Moseley wrote:
> Pinging on this.   Is this new behavior?   I don't remember seeing these
> warnings before -- and I am curious why the calling code needs to do this
> instead of DBIC.   Sorry if I'm missing something here.
> 
> On Sun, Aug 5, 2012 at 10:26 AM, Bill Moseley <moseley at hank.org> wrote:
> 
> > Running tests saw this message:
> >
> > DBIx::Class::ResultSet::search(): DateTime objects passed to search() are
> > not supported properly (InflateColumn::DateTime formats and settings are
> > not respected.) See "Formatting DateTime objects in queries" in
> > DBIx::Class::Manual::Cookbook.
> >
> > Cookbook suggests this:
> >
> >   my $dtf = $schema->storage->datetime_parser;
> >   my $rs = $schema->resultset('users')->search(
> >     {
> >       signup_date => {
> >         -between => [
> >           $dtf->format_datetime($dt_start),
> >           $dtf->format_datetime($dt_end),
> >         ],
> >       }
> >     },
> >   );
> >
> >
> > I'm curious.  If DBIC knows it's a DateTime object and DBIC has a method
> > to format it correctly then why is there a warning?  Why not just format it?

It never had a method to format it correctly in *all* cases. It can format 
it correctly 95% of the time (this is not really fixable either, it's an 
architectural deficiency). Hence the warning and leaving it to the user to 
make sure they are getting what they expect.

Cheers




More information about the DBIx-Class mailing list