[Dbix-class] Re: RFC: Patch for InflateColumn::Datetime to handle
invalid date
John Napiorkowski
jjn1056 at yahoo.com
Sat Jun 16 19:13:25 GMT 2007
--- Matt S Trout <dbix-class at trout.me.uk> wrote:
> On Fri, Jun 15, 2007 at 09:46:21AM -0600, Eric
> Waters wrote:
> > > Any thoughts? What would you all like (if
> anything)
> > > in terms of a solution for this. I can get some
> paid
> > > time to work on this for us. Please don't say
> > > "Postgresql", I don't have that option on this
> > > contract.
> >
> > I'm not sure if this is the "best" way to handle
> it, but it's the way I've handled it. I don't know
> the best way to handle the error; I think I would
> rather see it return undef even though as has been
> mentioned MySQL isn't consistent on wether it's null
> or not. I think the alternative would be to return
> a pseudo-DateTime object that represents
> "0000-00-00" in some way.
> >
> > @@ -62,11 +63,21 @@ sub register_column {
> > {
> > inflate => sub {
> > my ($value, $obj) = @_;
> > -
> $obj->_datetime_parser->$parse($value);
> > + return undef if ! defined
> $value;
> > +
> > + my $dt;
> > + eval { $dt =
> $obj->_datetime_parser->$parse($value) };
> > + #cluck $@ if $@;
> > + return $dt;
> > },
> > deflate => sub {
> > my ($value, $obj) = @_;
> > -
> $obj->_datetime_parser->$format($value);
> > + return $value if ! $value
> || ! ref($value);
> > +
> > + my $str;
> > + eval { $str =
> $obj->_datetime_parser->$format($value) };
> > + #cluck $@ if $@;
> > + return $str;
> > },
> > }
> > );
>
> That's a cute workaround for MySQL being stupid.
>
> Please submit it as a patch for
> DateTime::Format::MySQL - database specific
> code has no place at all in InflateColumn::DateTime
> - the various databases
> stupidities should be encapsulated behind the
> storage api ...
Sounds right to me. For now I'll just handle it as a
hack. --john
>
> --
> Matt S Trout Need help with your
> Catalyst or DBIx::Class project?
> Technical Director Want a managed development
> or deployment platform?
> Shadowcat Systems Ltd. Contact mst (at)
> shadowcatsystems.co.uk for a quote
> http://chainsawblues.vox.com/
> http://www.shadowcatsystems.co.uk/
>
> _______________________________________________
> List:
>
http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN:
>
http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
> Searchable Archive:
>
http://www.mail-archive.com/dbix-class@lists.rawmode.org/
>
____________________________________________________________________________________
Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.com/
More information about the Dbix-class
mailing list