[Dbix-class] updating a has_many relationship failure
Ihnen, David
dihnen at amazon.com
Tue Feb 2 18:42:23 GMT 2010
It expects the object of the opposing table row there, not a hash - hence the error. This is how I would do it.
$album->update({ record_label => App->model('AppDB::Labels')->find({ label_name => "Dischord" }) });
David
-----Original Message-----
From: Jon [mailto:jon at texttoall.com]
Sent: Tuesday, February 02, 2010 8:04 AM
To: DBIx::Class user and developer list
Subject: [Dbix-class] updating a has_many relationship failure
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
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
More information about the DBIx-Class
mailing list