[Catalyst] (no subject)

will trillich will.trillich at serensoft.com
Fri Sep 1 14:33:13 GMT 2017


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




-- 
"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/20170901/3242d834/attachment.htm>


More information about the Catalyst mailing list