Implement XQuery 4.0 record type support#6210
Open
joewiz wants to merge 2 commits intoeXist-db:developfrom
Open
Implement XQuery 4.0 record type support#6210joewiz wants to merge 2 commits intoeXist-db:developfrom
joewiz wants to merge 2 commits intoeXist-db:developfrom
Conversation
4 tasks
5d602ce to
fa65c7c
Compare
Add record type support to eXist-db's type system, laying the groundwork for XQ4 record type annotations (record(name as xs:string, age? as xs:integer, *)). Type system: - Type.RECORD = 70, subtype of MAP_ITEM (aligned with parser-next branch) - RecordType class with FieldDeclaration (name, type, optional flag) - Extensible records (trailing "*") support - RecordType.matches() validates map contents against field declarations SequenceType integration: - isRecordType(), getFieldDeclarations(), isRecordExtensible() API - setRecordType()/getRecordType() for parser integration - checkType() delegates to RecordType.matches() for runtime validation DynamicTypeCheck: - Maps pass through record type check (handled by SequenceType.checkType) Tests: 7 unit tests covering type hierarchy, field declarations, optional fields, extensible records, toString output, and SequenceType record API. Parser support (field accessor .name syntax, record test parsing) requires coordination with parser-next branch and will follow in a separate commit. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…(Phase 3-4) Phase 3 — FieldAccessor expression: - New FieldAccessor class evaluates $expr.fieldName as map:get($expr, "fieldName") - Returns empty sequence for missing fields, XPTY0004 for non-map base - Parser-next branch will wire the .NCName postfix syntax to this class Phase 4 — Record type checking in function arguments: - RecordTypeCheck wraps function arguments declared with record types - Validates at runtime: argument is a map, has all required fields, field types match, no extra keys (unless extensible) - Wired into Function.checkArgumentType() (both typeMatches and non-match paths) alongside existing FunctionTypeCheck pattern - Also wired into UserDefinedFunction.eval() for runtime parameter validation - Descriptive error messages: "missing required field 'age'" etc. 10 new tests (4 FieldAccessor + 6 RecordTypeCheck), all 17 tests passing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
fa65c7c to
a6626a9
Compare
Member
Author
|
[This response was co-authored with Claude Code. -Joe] CI state: 8/9 checks pass. The 1 remaining failure (ubuntu integration) is a pre-existing test hang unrelated to this PR. Dependencies: None. This PR is Wave 1 — it can be reviewed and merged independently. For full context on all 7.0 PRs and the merge order, see the Reviewer Guide. |
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.
Summary
Adds record type declarations and pattern matching per the XQuery 4.0 spec.
Tests
Spec References
Test plan
🤖 Generated with Claude Code