Allow non-unique region names #5718

Closed
opened 2025-12-29 19:31:47 +01:00 by adam · 6 comments
Owner

Originally created by @jabehnken on GitHub (Nov 29, 2021).

NetBox version

v3.0.9

Feature type

Change to existing functionality

Proposed functionality

Remove the uniqueness constraint on regions, so that multiple objects can be created with the same name. As an alternative to removing the uniqueness altogether, a combination of parent region, and region name could be used instead of region name alone.

Use case

The need was discovered when abbreviating Canada and California using their standard ISO 2 letter code CA. When inputting the second region with the same name, an error is received indicating another region with the same name already exists. The error comes up twice if the slug is the same. While abbreviations may not be the best practice for use in Regions, the same issue occurs using city names. An example:

United States of America

  • Missouri
    • Springfield
  • Nebraska
    • Springfield
  • Ohio
    • Springfield

Database changes

No response

External dependencies

No response

Originally created by @jabehnken on GitHub (Nov 29, 2021). ### NetBox version v3.0.9 ### Feature type Change to existing functionality ### Proposed functionality Remove the uniqueness constraint on regions, so that multiple objects can be created with the same name. As an alternative to removing the uniqueness altogether, a combination of parent region, and region name could be used instead of region name alone. ### Use case The need was discovered when abbreviating Canada and California using their standard ISO 2 letter code CA. When inputting the second region with the same name, an error is received indicating another region with the same name already exists. The error comes up twice if the slug is the same. While abbreviations may not be the best practice for use in Regions, the same issue occurs using city names. An example: United States of America - Missouri - Springfield - Nebraska - Springfield - Ohio - Springfield ### Database changes _No response_ ### External dependencies _No response_
adam added the type: featurestatus: duplicate labels 2025-12-29 19:31:47 +01:00
adam closed this issue 2025-12-29 19:31:47 +01:00
Author
Owner

@DanSheps commented on GitHub (Nov 30, 2021):

We would need to change the enforcement of uniqueness, currently it is done in the database.

We should not have duplicate region names within the same parent region, so I think enforcing uniqueness on parent + region would be ideal.

One gotcha is that we would need to either do the check in code (thus allowing you to bypass it using raw database calls) or through a unique index that coaleses the two strings as each null is "different" when looking at the PoV of the database (parent=None, name="Springfield") and (parent=None, name="Springfield") are considered Unique because the parent is null

I am going to put this up for volunteers.

@DanSheps commented on GitHub (Nov 30, 2021): We would need to change the enforcement of uniqueness, currently it is done in the database. We should not have duplicate region names within the same parent region, so I think enforcing uniqueness on parent + region would be ideal. One gotcha is that we would need to either do the check in code (thus allowing you to bypass it using raw database calls) or through a unique index that coaleses the two strings as each null is "different" when looking at the PoV of the database (parent=None, name="Springfield") and (parent=None, name="Springfield") are considered Unique because the parent is null I am going to put this up for volunteers.
Author
Owner

@jeremystretch commented on GitHub (Dec 1, 2021):

This change should be replicated to site groups as well, as they parallel regions.

@jeremystretch commented on GitHub (Dec 1, 2021): This change should be replicated to site groups as well, as they parallel regions.
Author
Owner

@jabehnken commented on GitHub (Dec 1, 2021):

Is this a duplicate that may already be getting implemented in 3.1?

https://github.com/netbox-community/netbox/issues/7354

@jabehnken commented on GitHub (Dec 1, 2021): Is this a duplicate that may already be getting implemented in 3.1? https://github.com/netbox-community/netbox/issues/7354
Author
Owner

@DanSheps commented on GitHub (Dec 1, 2021):

You are absolutely correct.

@DanSheps commented on GitHub (Dec 1, 2021): You are absolutely correct.
Author
Owner

@DanSheps commented on GitHub (Dec 1, 2021):

Duplicate of #7354

@DanSheps commented on GitHub (Dec 1, 2021): Duplicate of #7354
Author
Owner

@jeremystretch commented on GitHub (Dec 2, 2021):

I knew this sounded super familiar but couldn't find the other issue for some reason.

@jeremystretch commented on GitHub (Dec 2, 2021): I knew this sounded super familiar but couldn't find the other issue for some reason.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5718