Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor db relationships #114

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

pstaabp
Copy link
Member

@pstaabp pstaabp commented Aug 22, 2022

This changes assessor names in the DBIx::Class relationships for consistency. For singular relationships, the 's' has been dropped.

Note: this is based on #106, which has some changes to the CourseSettings database tables.

WIP: work on course_settings

WIP: continued work on the course settings

WIP: continued work on course_settings.

TEST: mojolicious route testing for settings.

WIP: continued work on course settings
perltidy
WIP: allow default settings to be defined in an override file.
WIP: fix up tests and general cleanup.


WIP: fix up tests and general cleanup.
FIX: fixes after rebasing.
Copy link
Member

@drdrew42 drdrew42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many-to-many relationships are also pluralized.

@@ -66,16 +66,16 @@ __PACKAGE__->set_primary_key('course_id');

# set up the many-to-many relationship to users
__PACKAGE__->has_many(course_users => 'DB::Schema::Result::CourseUser', 'course_id');
__PACKAGE__->many_to_many(users => 'course_users', 'users');
__PACKAGE__->many_to_many(users => 'course_users', 'user');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should remain plural.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was using the example in https://metacpan.org/pod/DBIx::Class::Relationship#many_to_many

It seems that the 3rd argument is the same as the belongs_to in the bridging table. I don't think this is an accessor name. The example cited above used singular for this relationship (actor and role).

@@ -63,6 +63,6 @@ __PACKAGE__->add_columns(

__PACKAGE__->set_primary_key('db_perm_id');
__PACKAGE__->has_many(db_perm_roles => 'DB::Schema::Result::DBPermRole', 'db_perm_id');
__PACKAGE__->many_to_many(roles => 'db_perm_roles', 'roles');
__PACKAGE__->many_to_many(roles => 'db_perm_roles', 'role');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should remain plural.

__PACKAGE__->has_many(db_perm_roles => 'DB::Schema::Result::DBPermRole', 'role_id');
__PACKAGE__->many_to_many(db_perms => 'db_perm_roles', 'db_perms');
__PACKAGE__->many_to_many(db_permissions => 'db_perm_roles', 'db_permission');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should remain plural.

@@ -115,6 +115,6 @@ __PACKAGE__->set_primary_key('user_id');
__PACKAGE__->add_unique_constraint([qw/username/]);

__PACKAGE__->has_many(course_users => 'DB::Schema::Result::CourseUser', 'user_id');
__PACKAGE__->many_to_many(courses => 'course_users', 'courses');
__PACKAGE__->many_to_many(course => 'course_users', 'course');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should remain plural.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants