add datetime_undef_if_invalid=0 loader option for MySQL
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / DBI / mysql.pm
index 357cb75..95e5e14 100644 (file)
@@ -176,6 +176,11 @@ EOF
                 delete $info->{size};
             }
         }
+        elsif ($info->{data_type} =~ /^(?:date(?:time)?|timestamp)\z/) {
+            if (not (defined $self->datetime_undef_if_invalid && $self->datetime_undef_if_invalid == 0)) {
+                $info->{datetime_undef_if_invalid} = 1;
+            }
+        }
 
         # Sometimes apparently there's a bug where default_value gets set to ''
         # for things that don't actually have or support that default (like ints.)