Repository navigation
Fix schema viewer omitting children of ref'd global elements with named complex types - #230
Open
JieXiong9119 wants to merge 1 commit into
Open
JieXiong9119 wants to merge 1 commit into
JieXiong9119 wants to merge 1 commit into
Conversation
… node version for pre-commit
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
The dictionary tree (
/dictionary/<version>/) shows no children for elements that are used throughref="auc:X"when the global element is declared as<xs:element name="X" type="auc:XType"/>andXTypeis a namedxs:complexType. In v2.7.0 this affectsFanBased,TimeSeries,CalculationMethodandPortfolioManager, among others. See #229.Root cause
_walk_named_element()inbsyncviewer/lib/schema_parser.pylooked up the element's named type but only handled the case where it was aSimpleTypeElement(enumerations). AComplexTypeElementwas found and then ignored, so its children were never added. Elements declared locally withname+typego 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 namedComplexTypeElementwith_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: addsTestRefNamedComplexType, which runs the parser on a small inline XSD with no database. It checks that:ref'd element and a local element of the same named type both get their children, with correct paths and tree levels;README.md: adds a warning about re-parsing schemas that are already in the database (see Deployment notes).Testing
TestRefNamedComplexTypetests pass locally (Python 3.6 conda env)tox -e pythontox -e precommitFanBased,TimeSeries,CalculationMethodandPortfolioManagersubtrees in the dictionary viewDeployment 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:
reset_schema --overwritedeletes 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.