[Dbix-class] Inserting empty string into DATETIME field in MySQL

Peter Wood pwood at christianbook.com
Mon Oct 10 18:30:29 GMT 2011


Hello,

I'm trying to insert an empty string into a datetime field in MySQL version 5.0.18, using DBIx::Class version 0.08120. This particular field is defined like so, within a call to 'add_columns':

__PACKAGE__->add_columns(
..snip..
"start_date",
  {
    data_type => "DATETIME",
    default_value => undef,
    is_nullable => 1,
    size => 19,
  },
..snip..
);

If I provide a complete value for start_date (eg 2011-10-10 14:29:27), everything works fine. However, when I try to set it to the empty string (''), the value inserted in the database is '0000-00-00 00:00:00'. If I run an insert on the command-line mysql client, and provide the empty string as the value for that field, it properly sets an empty value in the database.

Is there something else I should be doing to properly insert an empty string into this column?

Thanks,

Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20111010/3e9fdbfc/attachment.htm


More information about the DBIx-Class mailing list