[Dbix-class] missing 'many-to-many' relationship

Steve steve at matsch.com
Tue Aug 3 13:04:39 GMT 2010


Hi all,
I am bewildered as to why my 'many_to_many' relationship is being ignored.
I get an error when trying to use the relationship because it 'does not 
exist',
and clearly it doesn't.  WHY?
My result classes are 'User.pm', 'Role.pm', and 'UserRole.pm'.
I'm using the DBIC::Loader to generate the 'has_many', and 'belongs_to'
relationships, which leaves me to create the 'many_to_many' relationship
manually.

The User.pm result class relationships:
(generated by loader)
__PACKAGE__->has_many("user_roles", "DCO::Schema::Result::UserRole",
    { "foreign.users_id" => "self.id" });

(written by me)
__PACKAGE__->many_to_many('roles', 'user_roles', 'role');

I set a breakpoint for the debugger just prior to the 1; at the end of 
the package
and interrogated the schema. I clearly see that the 'user_roles' 
relationship exists,
but the 'roles' relationship does not.  No syntax errors, all other 
relationships
are being used successfully in the schema.

Any clue as to why this relationship is not created?

Thanks as always,
Steve




More information about the DBIx-Class mailing list