Perl 为什么我要从DBIx::Class::InflateColumn::DateTime对象中使用sprintf中未初始化的值?
这似乎是在我升级DBIx::类之后开始的,我不知道我做错了什么Perl 为什么我要从DBIx::Class::InflateColumn::DateTime对象中使用sprintf中未初始化的值?,perl,dbix-class,Perl,Dbix Class,这似乎是在我升级DBIx::类之后开始的,我不知道我做错了什么 Use of uninitialized value in sprintf at /opt/perl-5.10.1/lib/site_perl/5.10.1/DBIx/Class/InflateColumn/DateTime.pm line 192. at /opt/perl-5.10.1/lib/site_perl/5.10.1/DBIx/Class/InflateColumn/DateTime.pm line 192
Use of uninitialized value in sprintf at /opt/perl-5.10.1/lib/site_perl/5.10.1/DBIx/Class/InflateColumn/DateTime.pm line 192.
at /opt/perl-5.10.1/lib/site_perl/5.10.1/DBIx/Class/InflateColumn/DateTime.pm line 192
DBIx::Class::InflateColumn::DateTime::_flate_or_fallback('OpusVL::AppKitX::TelecomsBilling::Schema::Result::AsteriskCdr...', '2009-11-13 09:00:00', 'HASH(0x2a85488)', 'parse_%s') called at /opt/perl-5.10.1/lib/site_perl/5.10.1/DBIx/Class/InflateColumn/DateTime.pm line 199
我在结果文件中的列定义是
package Module1::Schema::Result::AsteriskCdrRecord;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
use strict;
use warnings;
use Moose;
use MooseX::NonMoose;
use namespace::autoclean;
extends 'DBIx::Class::Core';
__PACKAGE__->load_components("InflateColumn::DateTime");
__PACKAGE__->table("asterisk_cdr_records");
__PACKAGE__->add_columns(
"record_id",
{
data_type => "integer",
is_auto_increment => 1,
is_nullable => 0,
sequence => "asterisk_cdr_records_record_id_seq",
},
"import_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"line",
{ data_type => "integer", is_nullable => 0 },
"account_ref",
{ data_type => "varchar", is_foreign_key => 1, is_nullable => 0, size => 20 },
"b_number",
{ data_type => "varchar", is_nullable => 0, size => 80 },
"call_start",
{ data_type => "timestamp", is_nullable => 0 },
"call_end",
{ data_type => "timestamp", is_nullable => 0 },
"created",
{
data_type => "timestamp",
default_value => \"current_timestamp",
is_nullable => 0,
original => { default_value => \"now()" },
},
"updated",
{
data_type => "timestamp",
default_value => \"current_timestamp",
is_nullable => 0,
original => { default_value => \"now()" },
},
);
__PACKAGE__->set_primary_key("record_id");
__PACKAGE__->add_unique_constraint(
"idx_astcdr_records_uni",
["account_ref", "b_number", "call_start", "call_end"],
);
__PACKAGE__->belongs_to(
"import_id",
"Module1::Schema::Result::AsteriskCdrImport",
{ import_id => "import_id" },
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);
# Created by DBIx::Class::Schema::Loader v0.07002 @ 2010-10-15 10:08:29
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:mKgpEpbGV/m/CgsjvKLzZA
__PACKAGE__->load_components(qw/TimeStamp Core/);
# Adjust some column data that was automatically output by the _create.pl script.
__PACKAGE__->add_columns
(
# Force these to inflate via DataTime.
"call_start",
{
inflate_datetime => 1 ,
data_type => "timestamp without time zone",
default_value => undef,
is_nullable => 0,
size => 8,
},
"call_end",
{
inflate_datetime => 1,
data_type => "timestamp without time zone",
default_value => undef,
is_nullable => 0,
size => 8,
},
# Add automatic date handling
"created",
{ data_type => 'datetime', set_on_create => 1 },
"updated",
{ data_type => 'datetime', set_on_create => 1, set_on_update => 1 },
);
中断后再次执行操作的麻烦在于防止Schema::Loader在修改生成的代码时遇到问题
我需要做什么来防止关于未初始化值的警告?这是使用DBIx::Class的0.08124版本(虽然我认为它也出现在以前的版本中,但我当时没有着手调查这个问题)。改进上述代码的几点:
- 从第二个load_components调用中删除额外的“Core”,它已经在“extends”行中了
- 第二个“add_columns”调用可以通过使用新的“+col”语法来缩短,该语法允许您修改/更新现有的列定义,而不是添加一个全新的列定义,请参阅