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

Do not allow top_level to be a child of another subclass #285

Open
daveshm opened this issue Dec 11, 2024 · 0 comments
Open

Do not allow top_level to be a child of another subclass #285

daveshm opened this issue Dec 11, 2024 · 0 comments

Comments

@daveshm
Copy link

daveshm commented Dec 11, 2024

Environment

  • DiffSync version:
    2.1

Proposed Functionality

Do not allow top_level models to be a child of another subclass.

For example, when:

class Site(DiffSyncModel):
    _modelname = "site"
    _identifiers = ("resource_id",)

class Location(DiffSyncModel):
    _modelname = "location"
    _identifiers = ("resource_id",)
    _children = {"site": "sites"}

And the DiffSync implementation includes:

class MyDiffSync(DiffSync):
    top_level = ["location", "site"]

    location = Location
    site = Site

This configuration causes duplication of site models during diff and sync operations, as they are treated both as independent top-level models and as children of location.

Use Case
Users who define complex hierarchies in their DiffSync models would benefit from this feature by avoiding duplication in diff and sync results. This would improve data consistency and ensure that models have clear and non-overlapping roles.

For example, if Site is both a top-level model and a child of Location, performing a diff might result in Site objects being reported twice: once as part of the top-level site model and again as part of the location hierarchy. Disallowing this configuration ensures clean and predictable behavior for synchronization processes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant