diffsync icon indicating copy to clipboard operation
diffsync copied to clipboard

Do not allow top_level to be a child of another subclass

Open daveshm opened this issue 1 year ago • 0 comments

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.

daveshm avatar Dec 11 '24 06:12 daveshm