Skip to content

fix(tIED): scope LNode deduplication to the LNode's parent container - #159

Merged
danyill merged 1 commit into
openscd:mainfrom
danyill:issue-158-lnode-container
Oct 21, 2026
Merged

danyill merged 1 commit into
openscd:mainfrom
danyill:issue-158-lnode-container

Conversation

@danyill

@danyill danyill commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

removeIED(..., { preserveLNodes: true }) deduplicated preserved LNodes by ln.closest('Bay, VoltageLevel, Substation'), but the SCL schema applies the uniqueness constraint to the LNode's immediate parent container (e.g. ConductingEquipment, Function). An unbound LNode in one container therefore caused a bound LNode with the same key in a sibling container under the same Bay to be deleted instead of preserved as iedName="None".

  • Use ln.parentElement as the deduplication scope.
  • Add each LNode changed to iedName="None" to the cache during the call, so duplicate keys among the bound LNodes handled in one call are also detected.
  • Key fields (lnInst, lnClass, ldInst, prefix) are unchanged; iedName is not part of the key.

Tests

  • New regression test with the same LNode key in two ConductingEquipment containers, one already unbound. Verifies the returned edits and the document after applying them.
  • New test for two bound LNodes with the same key in one container, verifying one becomes iedName="None" and the other is removed.
  • Full suite passes: 576 tests, 99.62% coverage.

Closes #158

The SCL schema applies the LNode uniqueness constraint to the LNode's
immediate parent container, but detachLNodeBindings grouped unbound LNodes
by the nearest Bay, VoltageLevel or Substation. A bound LNode in one
ConductingEquipment could therefore be deleted because an unbound LNode
with the same key existed in a sibling container under the same Bay.

Use the parent element as the scope and add each LNode changed to
iedName="None" to the cache, so duplicate keys among the bound LNodes
handled in a single call are also detected.

Closes openscd#158

@stee-re stee-re left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its definitely

Comment thread tIED/removeIED.testfile.ts
@danyill
danyill merged commit d8dc0cb into openscd:main Oct 21, 2026
1 check passed
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

Successfully merging this pull request may close these issues.

detachLNodeBindings uses incorrect container

2 participants