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 for recursive data models #225

Open
Kircheneer opened this issue Apr 11, 2023 · 1 comment
Open

Allow for recursive data models #225

Kircheneer opened this issue Apr 11, 2023 · 1 comment
Labels
status: accepted This issue has been accepted by the maintainers team for implementation status: blocked Another issue or external requirement is preventing implementation type: enhancement

Comments

@Kircheneer
Copy link
Collaborator

Environment

  • DiffSync version: latest

Proposed Functionality

Allow for models to have a model of their own type as children.

Use Case

When modelling locations for example, a location of type country might have locations of type city as its children. Example (assuming #222 is implemented):

class Location(DiffSyncModel):
    _modelname = "location"
    _identifiers = ("name", "location_type", "$parent")
    _children = {"location": "location_children"}

    name: str
    location_type: str

    location_children: List['Location'] = []
@Kircheneer Kircheneer added status: accepted This issue has been accepted by the maintainers team for implementation status: blocked Another issue or external requirement is preventing implementation type: enhancement labels Apr 11, 2023
@jamesharr
Copy link
Contributor

Duplicate #238 has some more example model code that might be useful for initial testing.

The short version is that it looks like it's not far away from working. Where it's broken right now is that children items are processed multiple times.

I don't know the internals well enough to know if this is a change to an iteration method to avoid double processing items, or if it's more of a structural change where the API will need to change to support multiple backends

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 status: blocked Another issue or external requirement is preventing implementation type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants