Skip to content

TEDEFO-1854 Align toolkit to improved uniqueness testing#131

Merged
bertrand-lorentz merged 2 commits intodevelopfrom
TEDEFO-1854-improve-uniqueness-testing
Feb 9, 2026
Merged

TEDEFO-1854 Align toolkit to improved uniqueness testing#131
bertrand-lorentz merged 2 commits intodevelopfrom
TEDEFO-1854-improve-uniqueness-testing

Conversation

@rousso
Copy link
Contributor

@rousso rousso commented Feb 4, 2026

  • Implement typed uniqueness conditions (any value in any collection)
  • Fix: repeatable fields used as own context treated as scalar
  • Rename error code EXPECTED_SEQUENCE to EXPECTED_SCALAR

- Implement typed uniqueness conditions (any value in any collection)
- Fix: repeatable fields used as own context treated as scalar
- Rename error code EXPECTED_SEQUENCE to EXPECTED_SCALAR
void testUniqueValueCondition() {
testExpressionTranslationWithContext(
"count(for $x in PathNode/TextField, $y in /*/PathNode/TextField[. = $x] return $y) = 1",
"count(/*/PathNode/TextField/normalize-space(text())[. = PathNode/TextField/normalize-space(text())]) = 1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a valid XPath expression: /*/PathNode/TextField/normalize-space(text()) is not a node, it is a list of strings, so it cannot be used with a predicate.

In addition, the content of the predicate does not do what we need: the right hand-side of . = PathNode/TextField/normalize-space(text()) looks for a PathNode under the current TextField.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. The typed uniqueness conditions now use a for loop to bind the needle value before filtering the haystack:

count(for $n in needle, $x in haystack[. = $n] return $x) = 1

This avoids both issues:

  • The predicate [. = $n] compares two atomic values (no path navigation from a string context)
  • The needle is evaluated in the outer context, so relative paths resolve correctly

Fixed in a06cc97.

@bertrand-lorentz bertrand-lorentz merged commit ddb18b2 into develop Feb 9, 2026
1 check passed
@bertrand-lorentz bertrand-lorentz deleted the TEDEFO-1854-improve-uniqueness-testing branch February 9, 2026 08:33
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.

2 participants