Hello,

I'm facing a weird problem with DBIx::Class (used through Catalyst).

> Caught exception in
> MIAPE::Controller::Experiment::Gel::Detection->make_detection_widget 
> "DBIx::Class::AccessorGroup::__ANON__(): Error executing 'INSERT INTO
> gel.detection_reagents_buffers (detection_reagents_buffers_id) VALUES (?)':
> ERROR:  null value in column "reagents_buffers" violates not-null
> constraint"

Well, this constraint exists, but the fact is I wasn't trying to insert 
anything into the database.
I have simplified the problem as much as I could to get a minimal code that 
triggers this behaviour. Here is the stack trace (with complete code of the 
action!):

> Stack Trace
> Package       Line    File
> MIAPE::Controller::Experiment::Gel::Detection         
32      /(...)/MIAPE/lib/MIAPE/Controller/Experiment/Gel/Detection.pm
> 
>   29: sub make_detection_widget : Global {
>   30:     my ($self, $c) = @_;
>   31:     my @buffers_Objs =
>               $c->model('MIAPEDB::User::UserDetectionReagentsBuffers')->all; 
>   32:     my %buffers = map {
>   33:         "buffers" => $_->detection_reagents_buffers->reagents_buffers
>   34:     }, @buffers_Objs;
>   35: }

My action has just these 7 lines of code.
I really don't understand why 
the "$_->detection_reagents_buffers->reagents_buffers" instruction ends up 
with an INSERT INTO !

I use nearly exact copies of that elsewhere (except that on other table and 
with other field names), and it works as expected (i.e. the values are pushed 
into the hash).

Do someone know where this come from, or has the slightest idea of how I could 
get rid of it and issue a SELECT ... FROM instead ?

I tried 
$_->detection_reagents_buffers->get_column('reagents_buffers') to explicitly 
get (and not set) the column, but I get the same error.

Below I include the models of the two tables involved. 

Thank you in advance for any help !
Xavier

=============================================================================
lib/MIAPEDB/Gel/DetectionReagentsBuffers.pm
> package MIAPEDB::Gel::DetectionReagentsBuffers;
> use base qw/DBIx::Class/;
> use utf8;
> __PACKAGE__->load_components(qw/UTF8Columns PK::Auto Core/);
> __PACKAGE__->table('gel.detection_reagents_buffers');
> __PACKAGE__->add_columns(qw/detection_reagents_buffers_id
>     reagents_buffers/);
> __PACKAGE__->set_primary_key(qw/detection_reagents_buffers_id/);
> __PACKAGE__->add_unique_constraint([qw/reagents_buffers/]);
> __PACKAGE__->utf8_columns(qw/reagents_buffers/);
> __PACKAGE__->has_many('user_detection_reagents_buffers' =>
>     'MIAPEDB::User::UserDetectionReagentsBuffers',
>     'detection_reagents_buffers');
> 1; 
=============================================================================
lib/MIAPEDB/User/UserDetectionReagentsBuffers.pm
> package MIAPEDB::User::UserDetectionReagentsBuffers;
> use base qw/DBIx::Class/;
> use utf8;
> __PACKAGE__->load_components(qw/UTF8Columns PK::Auto Core/);
> __PACKAGE__->table('users.user_detection_reagents_buffers');
> __PACKAGE__->add_columns(qw/owner detection_reagents_buffers short_name/);
> __PACKAGE__->set_primary_key(qw/owner short_name/);
> __PACKAGE__->add_unique_constraint([qw/owner detection_reagents_buffers
>     short_name/]); __PACKAGE__->utf8_columns(qw/short_name/);
> __PACKAGE__->belongs_to('detection_reagents_buffers' =>
>     'MIAPEDB::Gel::DetectionReagentsBuffers', 'detection_reagents_buffers');
> 1;

_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to