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

RoleRequiredRoleModelMixin Generates Migrations with blank=True, null=True #3291

Closed
whitej6 opened this issue Feb 12, 2023 · 2 comments · Fixed by #3301
Closed

RoleRequiredRoleModelMixin Generates Migrations with blank=True, null=True #3291

whitej6 opened this issue Feb 12, 2023 · 2 comments · Fixed by #3301
Assignees
Labels
type: bug Something isn't working as expected
Milestone

Comments

@whitej6
Copy link
Contributor

whitej6 commented Feb 12, 2023

Environment

  • Nautobot version (Docker tag too if applicable): 2.0.0a1
  • Python version: 3.8
  • Database platform, version: postgres
  • Middleware(s):

Steps to Reproduce

  1. Create model with RoleRequiredRoleModelMixin
  2. Run makemigrations

Expected Behavior

blank=False, null=False in the migration

Observed Behavior

blank=True, null=True in the migration

@glennmatthews glennmatthews added the type: bug Something isn't working as expected label Feb 13, 2023
@glennmatthews glennmatthews added this to the v2.0.0 milestone Feb 13, 2023
@jathanism
Copy link
Contributor

It looks like the nomenclature and assertions here need to be fixed:

https://github.com/nautobot/nautobot/blob/next/nautobot/extras/models/roles.py#L45-L64

  1. RoleModelMixin is calling RoleField() with no arguments. This should be the "required" version and should explicitly call RoleField(null=True, blank=True).
  2. RoleRequiredModelMixin is subclassing RoleModelMixin and instead should just also inherit from models.Model similar to RoleModelMixin, and should not be calling RoleField(null=False, blank=False).

It appears the naming is backward here and the inheritance should not be done in this way.

@glennmatthews
Copy link
Contributor

Implemented in #3301.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working as expected
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants