[Dbix-class] Re: RFC: Patch for InflateColumn::Datetime to handle
invalid date
John Napiorkowski
jjn1056 at yahoo.com
Fri Jun 15 21:46:35 GMT 2007
--- Eric Waters <ewaters at xmission.com> 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;
> },
> }
> );
Do we want this in the inflator module or in the
datetime parser for MySQL?
--john
____________________________________________________________________________________Ready for the edge of your seat?
Check out tonight's top picks on Yahoo! TV.
http://tv.yahoo.com/
More information about the Dbix-class
mailing list