Skip to content

Fix schema viewer omitting children of ref'd global elements with named complex types - #230

Open
JieXiong9119 wants to merge 1 commit into
developfrom
fix-schema-viewer-omitting-children-issue
Open

JieXiong9119 wants to merge 1 commit into
developfrom
fix-schema-viewer-omitting-children-issue

Conversation

@JieXiong9119

@JieXiong9119 JieXiong9119 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The dictionary tree (/dictionary/<version>/) shows no children for elements that are used through ref="auc:X" when the global element is declared as <xs:element name="X" type="auc:XType"/> and XType is a named xs:complexType. In v2.7.0 this affects FanBased, TimeSeries, CalculationMethod and PortfolioManager, among others. See #229.

Root cause

_walk_named_element() in bsyncviewer/lib/schema_parser.py looked up the element's named type but only handled the case where it was a SimpleTypeElement (enumerations). A ComplexTypeElement was found and then ignored, so its children were never added. Elements declared locally with name + type go through a different branch that already handled complex types, which is why those displayed correctly.

Changes

  • bsyncviewer/lib/schema_parser.py: _walk_named_element() now walks a named ComplexTypeElement with _walk_complex_element(). It uses the element's current path and tree level, the same as the simple-type branch. No other parser behavior changes.
  • bsyncviewer/tests/test_schema.py: adds TestRefNamedComplexType, which runs the parser on a small inline XSD with no database. It checks that:
    • a ref'd element and a local element of the same named type both get their children, with correct paths and tree levels;
    • enumeration values on the children are kept;
    • no paths are duplicated, and row indices run in order without gaps.
  • README.md: adds a warning about re-parsing schemas that are already in the database (see Deployment notes).

Testing

  • New TestRefNamedComplexType tests pass locally (Python 3.6 conda env)
  • New tests confirmed to fail without the fix
  • Full suite: tox -e python
  • Lint: tox -e precommit
  • Fresh import of v2.7.0 on a throwaway database, then check the FanBased, TimeSeries, CalculationMethod and PortfolioManager subtrees in the dictionary view

Deployment notes

This fix only affects schemas parsed after it is deployed. The trees already stored for published versions won't change until those schemas are re-parsed. Both current ways to re-parse damage existing data:

  • Unchecking "schema parsed" in the admin parses again without clearing the old attributes, so every path is duplicated and enumeration linking is skipped for the duplicated paths.
  • reset_schema --overwrite deletes the schema. That also deletes its use cases, its BEDES mappings and the uploaded enumerations file.

BEDES mapping CSVs are imported by attribute and enumeration database ID, not by path. After a rebuild, old CSVs can't be re-imported as-is; mappings have to be generated, reviewed and imported again.

Refreshing the published schemas safely is left for a follow-up issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

1 participant