> 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;
},
}
);
_______________________________________________
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/[email protected]/