@@ -254,6 +254,8 @@ func findSetLeaves(s GoStruct, orderedMapAsLeaf bool, opts ...DiffOpt) (map[*pat
254
254
return
255
255
}
256
256
257
+ isYangPresence := util .IsYangPresence (ni .StructField )
258
+
257
259
var sp [][]string
258
260
if pathOpt != nil && pathOpt .PreferShadowPath {
259
261
// Try the shadow-path tag first to see if it exists.
@@ -314,7 +316,9 @@ func findSetLeaves(s GoStruct, orderedMapAsLeaf bool, opts ...DiffOpt) (map[*pat
314
316
// treating it as a leaf (since it is assumed to be
315
317
// telemetry-atomic in order to preserve ordering of entries).
316
318
if (! isOrderedMap || ! orderedMapAsLeaf ) && util .IsValueStructPtr (ni .FieldValue ) {
317
- return
319
+ if ! isYangPresence {
320
+ return
321
+ }
318
322
}
319
323
if isOrderedMap && orderedMap .Len () == 0 {
320
324
return
@@ -334,9 +338,17 @@ func findSetLeaves(s GoStruct, orderedMapAsLeaf bool, opts ...DiffOpt) (map[*pat
334
338
}
335
339
}
336
340
337
- outs := out .(map [* pathSpec ]interface {})
338
- outs [vp ] = ival
339
-
341
+ // If the current field is tagged as a presence container,
342
+ // we set it's value to `nil` instead of returning earlier.
343
+ // This is because empty presence containers has a meaning,
344
+ // unlike a normal container.
345
+ if isYangPresence {
346
+ outs := out .(map [* pathSpec ]interface {})
347
+ outs [vp ] = nil
348
+ } else {
349
+ outs := out .(map [* pathSpec ]interface {})
350
+ outs [vp ] = ival
351
+ }
340
352
if isOrderedMap && orderedMapAsLeaf {
341
353
// We treat the ordered map as a leaf, so don't
342
354
// traverse any descendant elements.
0 commit comments