Subject: | Schema::Loader can't tell the difference between strings and functions as default values |
See the attached files; for a column that has CURRENT_TIMESTAMP as a
default, it's being parsed as the string 'CURRENT_TIMESTAMP', which will
fail upon insertion.
This information is built up in S::L::DBI::->_columns_info_for. If the
input is a function (detectable via SQL_DATA_TYPE perhaps), the value
should be prepended with a \:
$column_info{default_value} =
$this_default_is_a_function
? \$info->{COLUMN_DEF}
: $info->{COLUMN_DEF};
If i knew how to detect this portably, a patch would be attached :(
Subject: | input.txt |
mysql> show create table item;
| item | CREATE TABLE `item` (
`item_id` int(10) unsigned NOT NULL auto_increment COMMENT 'The index for the item table',
`created` timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY (`item_id`),
) ENGINE=InnoDB AUTO_INCREMENT=5900 DEFAULT CHARSET=latin1 PACK_KEYS=0 |
Subject: | output.txt |
package My::Schema::Result::Item;
use strict;
use warnings;
use base 'DBIx::Class';
__PACKAGE__->load_components("InflateColumn::DateTime", "Core");
__PACKAGE__->table("item");
__PACKAGE__->add_columns(
"item_id",
{ data_type => "INT", default_value => undef, is_nullable => 0, size => 10 },
"created",
{
data_type => "TIMESTAMP",
default_value => "CURRENT_TIMESTAMP",
is_nullable => 0,
size => 14,
},
__PACKAGE__->set_primary_key("item_id");