Fix XSD type name mapping for UnsignedInt and UnsignedByte#563
Open
gaoflow wants to merge 1 commit into
Open
Conversation
XSD_TYPE_NAMES mapped UnsignedInt to "unsignedByte" and had no entry for UnsignedByte. Since XSD_TYPE_CLASSES is the inverse, deserializing a value with valueType "xs:unsignedInt" raised KeyError, and "xs:unsignedByte" resolved to UnsignedInt instead of UnsignedByte. Map each type to its own XSD name. Fixes eclipse-basyx#560. Signed-off-by: gaoflow <gaobing1230@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
XSD_TYPE_NAMESinbasyx/aas/model/datatypes.pymappedUnsignedIntto"unsignedByte"and had no entry forUnsignedByteat all.Because
XSD_TYPE_CLASSESis generated as the inverse ofXSD_TYPE_NAMES, this produced two concrete failures (the deserializers look the value type up inXSD_TYPE_CLASSES, e.g.json_deserialization.py/xml_deserialization.py):XSD_TYPE_CLASSES["xs:unsignedInt"]was absent, so deserializing anyExtension,Property,Qualifier, … withvalueType: xs:unsignedIntraisedKeyError.XSD_TYPE_CLASSES["xs:unsignedByte"]returnedUnsignedIntinstead ofUnsignedByte— a silent wrong-class result.Fix
Map
UnsignedIntto"unsignedInt"and add the missingUnsignedByte: "unsignedByte"entry.Tests
Added
TestIntTypes.test_xsd_type_name_mapping, which checks the two specific mappings round-trip and, more generally, thatXSD_TYPE_CLASSESis a faithful inverse ofXSD_TYPE_NAMESfor every type (so no two types share an XSD name). It fails onmainand passes with the fix. The existingtest_datatypesand JSON/XML serialization tests stay green.Fixes #560.