Skip to content

Commit

Permalink
fix: Maintain compound field types ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
tefra committed Dec 16, 2023
1 parent 80ba4f4 commit aa1b9e4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions tests/codegen/handlers/test_create_compound_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
from xsdata.codegen.handlers import CreateCompoundFields
from xsdata.codegen.models import Restrictions
from xsdata.models.config import GeneratorConfig
from xsdata.models.enums import DataType
from xsdata.models.enums import Tag
from xsdata.utils import collections
from xsdata.utils.testing import AttrFactory
from xsdata.utils.testing import AttrTypeFactory
from xsdata.utils.testing import ClassFactory
from xsdata.utils.testing import ExtensionFactory
from xsdata.utils.testing import FactoryTestCase
Expand Down Expand Up @@ -92,7 +91,9 @@ def test_group_fields(self):
name="choice",
tag="Choice",
index=0,
types=list({t for attr in target.attrs for t in attr.types}),
types=collections.unique_sequence(
t for attr in target.attrs for t in attr.types
),
choices=[
AttrFactory.create(
tag=target.attrs[0].tag,
Expand Down
3 changes: 2 additions & 1 deletion xsdata/codegen/handlers/create_compound_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from xsdata.codegen.utils import ClassUtils
from xsdata.formats.dataclass.models.elements import XmlType
from xsdata.models.enums import Tag
from xsdata.utils import collections
from xsdata.utils.collections import group_by

ALL = "a"
Expand Down Expand Up @@ -88,7 +89,7 @@ def group_fields(self, target: Class, attrs: List[Attr]):

min_occurs, max_occurs = self.sum_counters(counters)
name = self.choose_name(target, names)
types = list({t for attr in attrs for t in attr.types})
types = collections.unique_sequence(t for attr in attrs for t in attr.types)

target.attrs.insert(
pos,
Expand Down

0 comments on commit aa1b9e4

Please sign in to comment.