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

will trillich will.trillich at serensoft.com
Mon Oct 2 15:31:11 GMT 2017


Hey y'all -- if there's something I can do to clarify my question, let me
know :)

This has me puzzled!

On Thu, Sep 7, 2017 at 9:23 AM, will trillich <will.trillich at serensoft.com>
wrote:

> 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!
>
>


-- 
 Will Trillich :: 812.454.6431

"Ask for nothing, and you will receive nothing." -- the folks at Global
Degree

“The cure to boredom is curiosity. There is no cure for curiosity.”

Dorothy Parker

Todo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/catalyst/attachments/20171002/9d8284f8/attachment.htm>


More information about the Catalyst mailing list