[Dbix-class] Problem with populate() and commits?

Peter Rabbitson rabbit+dbic at rabbit.us
Fri May 15 19:06:31 GMT 2009


Chris Cole wrote:
> 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??
> 

This is still strange - you shouldn't be getting internal code exception
without autocommit - it is immaterial at that point. You are saying that
line 46 is an update() but there is no update in the code above. Which one
is it?



More information about the DBIx-Class mailing list