diffsync icon indicating copy to clipboard operation
diffsync copied to clipboard

Add support for Unsorted List

Open dgarros opened this issue 5 years ago • 3 comments
trafficstars

Environment

  • DSync version: master

Proposed Functionality

Currently when an attribute is defined as a list, DSync will report a diff if the lists have the same content but in a different order. In some cases that's the expected behavior but in other cases the order doesn't matter and it's hard to predict how things will be loaded on both adapters. It would be great to be able to explicitly define if a list should be sorted or not when we are calculating the diff.

Use Case

In some cases it's hard to predict how a list will be loaded which can lead to false positive when we are generating the diff. A possible workaround is to ensure that, as we construct the list, the content is always ordered but it adds some complexity in the adapter.

dgarros avatar Oct 23 '20 10:10 dgarros

Can we just use set instead of list in this case, or is there a case where we want to preserve the order within the adapter and just ignore order when diffing?

glennmatthews avatar Oct 23 '20 11:10 glennmatthews

Speaking a bit out of school here, but I do think we want to keep order, but sometimes diff unordered

itdependsnetworks avatar Oct 23 '20 12:10 itdependsnetworks

That makes sense. This should be relatively simple to do within the scope of the existing DSyncModelFlags paradigm if we want this to be toggle at a per-model level; if we need it to be configurable at a per-field level (e.g. Site.devices should be sorted while Site.vlans should be unsorted) then that will of course be more complex to implement.

glennmatthews avatar Oct 23 '20 19:10 glennmatthews