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

Allow a parent reference in the identifiers #222

Open
Kircheneer opened this issue Mar 21, 2023 · 4 comments
Open

Allow a parent reference in the identifiers #222

Kircheneer opened this issue Mar 21, 2023 · 4 comments
Labels
status: accepted This issue has been accepted by the maintainers team for implementation type: enhancement

Comments

@Kircheneer
Copy link
Collaborator

Kircheneer commented Mar 21, 2023

Environment

  • DiffSync version: 1.7.1

Proposed Functionality

The _identifiers of a model should allow a reference to the parent's set of _identifiers.

Use Case

Taking a simple building -> floor parent-child hierarchy the 2nd floor only needs to be unique within its own building. Currently I have to do a workaround like this:

class Floor(DiffSyncModel):
    _identifiers = ("name", "building_name")

    name: str
    building_name: str

when I would much rather want to do something like this

class Floor(DiffSyncModel):
    _identifiers = ("name", "$parent")

    name: str

to make my floors unique where BuildingModel looks like this:

class Building(DiffSyncModel):
    _identifiers = ("name")
    _children = {"floor": "floors"}

    name: str
    floors: List[Floor] = []
@Kircheneer Kircheneer added status: accepted This issue has been accepted by the maintainers team for implementation type: enhancement labels Mar 21, 2023
@chadell
Copy link
Collaborator

chadell commented Mar 21, 2023

I guess this assumes this, doesn't it?:

class Building(DiffSyncModel):
    _identifiers = ("name")
    _children = {"floor": "floors"}

    name: str
    floors: List = []

@Kircheneer
Copy link
Collaborator Author

I guess this assumes this, doesn't it?:

Yes, thanks. Updated.

@itdependsnetworks
Copy link
Contributor

@Kircheneer
Copy link
Collaborator Author

I presume you are already referencing this, but in case not: https://github.com/nautobot/nautobot-plugin-ssot/pull/69/files#diff-d5a05dc0fa5ec399d2b02a105d518741cfc140ec6ce19c4694a3e8c1b8f3e9a7R98

Actually I am not, thanks! From what you linked I can't quite tell in which section you need this, but I think I get the general idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepted This issue has been accepted by the maintainers team for implementation type: enhancement
Projects
None yet
Development

No branches or pull requests

3 participants