Skip to content

Skip duplicate columns from xs:choice branches sharing a simple element - #85

Merged
martinv13 merged 1 commit into
cre-dev:mainfrom
martinv13:fix/issue-82-choice-simple-element
Oct 16, 2026
Merged

martinv13 merged 1 commit into
cre-dev:mainfrom
martinv13:fix/issue-82-choice-simple-element

Conversation

@martinv13

Copy link
Copy Markdown
Collaborator

Fixes #82.

When the same simple element appears in two branches of an xs:choice (for instance (id, urn?) | urn), add_column was called twice for it. self.columns kept a single entry but self.fields got two, so elevating the type into its parent failed with A column with name '..._urn' is already present.

add_column now skips a column when one with the same name and data type already exists, the same approach #60 took for relations.

Tests

  • orders.xsd gets catalogRefType, with the shape from the issue, used by item as an optional catalog_ref.
  • order3.xml covers both branches: one item uses id + urn, the other uses urn alone.
  • Without the fix, 38 tests fail with 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).
  • Snapshots regenerated: the only change is the new catalog_ref_id and catalog_ref_urn columns on item.

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

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>
@martinv13
martinv13 merged commit 30af431 into cre-dev:main Oct 16, 2026
10 checks passed
@martinv13
martinv13 deleted the fix/issue-82-choice-simple-element branch October 16, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simple element in two branches of a choice: column already present

1 participant