Skip to content

Allow a parent reference in the identifiersΒ #222

Open
@Kircheneer

Description

@Kircheneer

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] = []

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: acceptedThis issue has been accepted by the maintainers team for implementationtype: enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions