[Catalyst] error "Objects supplied as 'foreign_values' usually should inherit from the related ResultClass"

will trillich will.trillich at serensoft.com
Thu Sep 7 14:23:49 GMT 2017


This is a weird one.



Short version:

$userexam->user is defined as Auth::User, but seems like it gets redefined
as DB::User somewhere mysteriously.

How can I track that down?



Long version:

Split database setup: DB is for the application data, Auth is for user data.

The userexam table links users to the exams they take.
*Schema/DB/Result/UserExam.pm
*contains:

__PACKAGE__->belongs_to( user => 'Learn::Schema::Auth::Result::User' );
__PACKAGE__->belongs_to( exam => 'Learn::Schema::DB::Result::Exam' );

*Schema/DB/ResultSet/UserExam.pm* contains:

sub take { # take the exam
    my $rs      = shift; # Learn::Schema::DB::ResultSet::UserExam object
    my $user    = shift; # Learn::Model::Auth::User object
    my $exam    = shift; # Learn::Model::DB::Exam object
...
    my $user_exam = $rs->create({
        user => $user,
        exam => $exam,
    });
}

The error it throws at $rs->create() is:

*DBIx::Class::ResultSource::_resolve_relationship_condition(): *
*Objects supplied as 'foreign_values'
(Learn::Model::Auth::User=HASH(0xe022b14)) *
*usually should inherit from the related ResultClass
('Learn::Model::DB::User'), *
*perhaps you've made a mistake invoking the condition resolver? *

In the schema file
​,​
->user is defined as Auth::User. Somehow it gets redefined along the way
and Catalyst thin
​k
s it should be DB::User instead?!

Grepping for DB.*User (and variations) in schema files brings up
DB::UserExams and related info (DB::UserCourse, DB::UserRole,
DB::UserAnswer) but no DB::User at all.

How could that get redefined? Or is this a symptom of something else? I
could use a big clue stick upside the head :/

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/catalyst/attachments/20170907/f120ac98/attachment.htm>


More information about the Catalyst mailing list