Repository navigation
Skip duplicate columns from xs:choice branches sharing a simple element - #85
Merged
martinv13 merged 1 commit intoOct 16, 2026
Merged
Conversation
When the same simple element appears in two branches of an xs:choice, add_column was called twice: self.columns kept one entry but self.fields got two, which produced a duplicate column once the type was elevated into its parent. Skip the second column when one with the same name and data type exists, as done for relations in cre-dev#60. Add catalogRefType to orders.xsd to cover this case, with order3.xml exercising both branches. Fixes cre-dev#82 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.
Fixes #82.
When the same simple element appears in two branches of an
xs:choice(for instance(id, urn?) | urn),add_columnwas called twice for it.self.columnskept a single entry butself.fieldsgot two, so elevating the type into its parent failed withA column with name '..._urn' is already present.add_columnnow skips a column when one with the same name and data type already exists, the same approach #60 took for relations.Tests
orders.xsdgetscatalogRefType, with the shape from the issue, used byitemas an optionalcatalog_ref.order3.xmlcovers both branches: one item usesid+urn, the other usesurnalone.A column with name 'catalog_ref_urn' is already present in table 'item'. With it, the full suite passes on DuckDB (229 passed, 73 skipped).catalog_ref_idandcatalog_ref_urncolumns onitem.The same element name with different types in the two branches still raises the error. This PR does not change that case, since the issue does not report it.
🤖 Generated with Claude Code