Skip to content

Commit

Permalink
Improve XMLEventReader.maintainable()
Browse files Browse the repository at this point in the history
Handle the case where the existing object is concrete, not an external
reference, but has no URN set (e.g. because not given in the source
message) by computing a URN.
  • Loading branch information
khaeru committed Aug 28, 2024
1 parent 8bcd9e9 commit adafd2d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sdmx/reader/xml/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,10 +579,13 @@ def maintainable(self, cls, elem, **kwargs):
existing = self.get_single(cls, obj.id, version=obj.version)

if existing and (
existing.compare(obj, strict=True) or existing.urn == sdmx.urn.make(obj)
existing.compare(obj, strict=True)
or (existing.urn or sdmx.urn.make(existing)) == sdmx.urn.make(obj)
):
if elem is not None:
# Previously an external reference, now concrete
# FIXME Handle the case where a MaintainableArtefact is included in a
# StructureMessage, with is_external_reference explicitly True
existing.is_external_reference = False

# Update `existing` from `obj` to preserve references
Expand Down Expand Up @@ -616,6 +619,7 @@ def matching_class(cls):


def setdefault_attrib(target, elem, *names):
"""Update `target` from :py:`elem.attrib` for the given `names`."""
try:
for name in names:
try:
Expand Down

0 comments on commit adafd2d

Please sign in to comment.