create table foo (
test1 int not null auto_increment,
test2 int null,
primary key (test1)
);
####
package Foo;
use base 'Class::DBI';
__PACKAGE__->columns(
All => qw/test1 test2/
);
__PACKAGE__->add_trigger(before_create => \&trigger_code);
sub trigger_code {
my $self = shift;
$self->test2('123') unless $self->test2;
}
####
Foo->connection('dbi:mysql:dbname=testdb','root','');
Foo->create({});
####
Use of uninitialized value in split at /usr/local/share/perl/5.8.4/UNIVERSAL/can.pm line 51.
Called UNIVERSAL::can() as a function, not a method at /usr/local/share/perl/5.8.4/Class/DBI.pm line 265
Can't call method "can" on an undefined value at /usr/local/share/perl/5.8.4/UNIVERSAL/can.pm line 40.