[Dbix-class] Inserting empty string into DATETIME field in MySQL
btilly at gmail.com
Mon Oct 10 18:42:56 GMT 2011
The date you're getting is what you tend to get when MySQL sees that
there should be a value but can't parse the result.
Try passing in undef instead of an empty string and see if it works right.
On Mon, Oct 10, 2011 at 11:30 AM, Peter Wood <pwood at christianbook.com> wrote:
> 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':
> data_type => "DATETIME",
> default_value => undef,
> is_nullable => 1,
> size => 19,
> 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?
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
More information about the DBIx-Class