[Dbix-class] updating a has_many relationship failure

Jon jon at texttoall.com
Tue Feb 2 16:04:13 GMT 2010


Hello,
I'm building a Catalyst app using dbix class.  This is the first app I
have built using dbix-class but I have a large part of the app built
when I came across this issue.

When I attempt to update a column in a row with a has_many
relationship I get the following error, and the update fails,
Can't call method "isa" on unblessed reference at
/usr/local/lib/perl5/site_perl/5.8.8/DBIx/Class/Relationship/Accessor.pm
line 59.

I think I must be doing something dumb wrong.  I just wrote some
sample code to test it,

my $album = App->model('AppDB::Albums')->find({
   album => 1
});
$album->update({
   record_label => {
       label_name => "Dischord",
   }
});

which of course results in the unblessed reference error above.
Here's the table Schema definition,

(in App::Schema::Result::Albums)
__PACKAGE__->belongs_to(record_label =>
'App::Schema::Result::RecordLabels','record_label');

(in App::Schema::Result::RecordLabels)
__PACKAGE__->has_many(albums => 'App::Schema::Result::Albums','record_label');

There are no issues when I insert rows, only when I update.  Here are
the relevant versions I am using,
perl 5.8.8
DBIx::Class         : 0.08115
Catalyst            : 5.80015

Any ideas?  Am I doing something wrong, or could an older version of
perl be the problem?

Thanks!

- Jon



More information about the DBIx-Class mailing list