<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<blockquote cite="mid:E1Im6oG-0005lQ-1C@jules.scsys.co.uk" type="cite">
  <blockquote type="cite">
    <pre wrap="">Ash Berlin wrote:
    </pre>
    <blockquote type="cite">
      <pre wrap="">I'm not sure if InflateColumn::DateTime will handle this better or not,
but its the first thing to try.

Ash
      </pre>
    </blockquote>
    <pre wrap="">InflateColumn::DateTime basically does the same thing.  The solution
would be to remove the corrupt data from the database, or maybe modify
DT::Format::MySQL to convert 0000-00-00 00:00:00 into "undef".  I think
0000-00-00 00:00:00 is meant to be treated as NULL, right?
    </pre>
  </blockquote>
  <pre wrap=""><!---->
I did this for (the inflate-side only) by creating a result base class
which overrides inflate_column and adding it to -&gt;load_components().

    package FixBrokenDates;

    use strict;
    use warnings;

    use base qw/DBIx::Class/;


    sub inflate_result {
        my $class = shift;
        my ($source, $me, $prefetch) = @_;

        # Nullify MySQL zero dates
        for my $col (keys %{$me}) {
            my $datatype = lc $source-&gt;column_info($col)-&gt;{data_type};
            if (($datatype eq 'date' &amp;&amp; $me-&gt;{$col} eq '0000-00-00') ||
                (($datatype eq 'datetime' || $datatype eq 'timestamp')
                 &amp;&amp; $me-&gt;{$col} eq '0000-00-00 00:00:00')) {
                $me-&gt;{$col} = undef;
            }
        }

        $class-&gt;next::method(@_);
    }

If the schema doesn't allow null columns you have to override
deflate_result similarly and fix up (or should that be "break up" :)
undef values in columns with is_nullable == 0.

  </pre>
</blockquote>
Very nice.&nbsp;&nbsp;&nbsp; I'll see if I can get that working in combination with
DBIx::Class::InflateColumn::DateTime<br>
<br>
Thanks very much.<br>
<br>
<pre class="moz-signature" cols="72">-- 
Randy Moore
Axion Information Technologies, Inc.

phone: 301-587-3300 x 511
fax:   301-585-7450

<a class="moz-txt-link-freetext" href="http://www.axion-it.com">http://www.axion-it.com</a>
</pre>
</body>
</html>