[Dbix-class] Problem with populate() and commits?
Chris Cole
chris at compbio.dundee.ac.uk
Thu May 14 16:24:07 GMT 2009
Hi,
Given this schema:
package DB::Schema::Species;
use strict;
use warnings;
use base 'DBIx::Class';
__PACKAGE__->load_components("Core");
__PACKAGE__->table("species");
__PACKAGE__->add_columns(
"species_id",
{
data_type => "SMALLINT",
default_value => undef,
is_nullable => 0,
size => 5,
},
"short_name",
{ data_type => "VARCHAR", default_value => "", is_nullable => 0, size
=> 255 },
"common_name",
{
data_type => "VARCHAR",
default_value => undef,
is_nullable => 1,
size => 255,
},
"full_name",
{ data_type => "VARCHAR", default_value => "", is_nullable => 0, size
=> 255 },
);
__PACKAGE__->set_primary_key("species_id");
__PACKAGE__->has_many(
"db_sequences",
"DB::Schema::DbSequences",
{ "foreign.species_id" => "self.species_id" },
);
__PACKAGE__->has_many(
"experiments",
"DB::Schema::Experiment",
{ "foreign.species" => "self.species_id" },
);
__PACKAGE__->has_many(
"genome_matches",
"DB::Schema::GenomeMatch",
{ "foreign.species_id" => "self.species_id" },
);
and this code:
my $schema = DB::Schema->connect(stuff);
my $species = $schema->resultset("Species");
$species->populate([
{ short_name => $shortName,
full_name => $longName,
common_name => $commonName }
]);
Why does it work fine when I have Autocommit 'on', but get the following
error with Autocommit 'off':
DBIx::Class::ResultSet::update(): Values for update must be a hash at
./add_species.pl line 46
Issuing rollback() for database handle being DESTROY'd without explicit
disconnect().
where line 46 is:
$species->update();
I don't get it??
More information about the DBIx-Class
mailing list