Audit registered collection changes by identity
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
// compareResolutionValues reports field-level changes at stable list positions.
|
||||
func compareResolutionValues(before, after *document.Node) []documentDelta {
|
||||
func compareResolutionValues(before, after *document.Node, correspondence ...resolutionCorrespondence) []documentDelta {
|
||||
var deltas []documentDelta
|
||||
var compare func(*document.Node, *document.Node, Path)
|
||||
compare = func(left, right *document.Node, path Path) {
|
||||
@@ -30,6 +30,25 @@ func compareResolutionValues(before, after *document.Node) []documentDelta {
|
||||
compare(value, nil, path.Key(key))
|
||||
}
|
||||
case document.Sequence:
|
||||
if len(correspondence) != 0 {
|
||||
if collection, registered := correspondence[0].collections[path.String()]; registered {
|
||||
if !collection.eligible {
|
||||
if !configurationValuesEqual(left, right) {
|
||||
deltas = append(deltas, documentDelta{path: path.clone(), kind: documentReplaced})
|
||||
}
|
||||
return
|
||||
}
|
||||
if collection.structural {
|
||||
deltas = append(deltas, documentDelta{path: path.clone(), kind: documentReplaced})
|
||||
}
|
||||
for finalIndex, entryIndex := range collection.finalToEntry {
|
||||
if entryIndex >= 0 {
|
||||
compare(left.Sequence[entryIndex], right.Sequence[finalIndex], path.Index(finalIndex))
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
if len(left.Sequence) != len(right.Sequence) {
|
||||
deltas = append(deltas, documentDelta{path: path.clone(), kind: documentReplaced})
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user