Add conformance test for forEach nested via select inside forEachOrNull
- Dominant language
- JavaScript
- Stars
- 0
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
The conformance suite exercises a `forEach` nested inside a `forEachOrNull` only through `unionAll` (the "forEachOrNull & unionAll on the same level" case in `tests/foreach.json`), and a `forEach` nested via `select` only inside another `forEach` (the "nested forEach: select & column" case). A `forEach` nested directly via `select` inside a `forEachOrNull` is not covered.
That combination is worth a dedicated case because it diverges from the `unionAll` one when the inner collection is empty. Under `unionAll` the null row that `forEachOrNull` guarantees survives, because the sibling column branch is unioned alongside the empty `forEach` branch. Under `select` it does not: the column and the nested `forEach` are combined as a Cartesian product, so an empty `forEach` collapses the whole row and the guaranteed null row disappears. An implementation can therefore pass the existing `unionAll` case and still get the `select` case wrong, so the behaviour is currently unguarded.
Here is a self-contained case that closes the gap. With `pt1` carrying two names where only the first has `given` values, and `pt2` carrying no name at all, `pt1`'s second name and the whole of `pt2` collapse, leaving two rows. The expected rows were checked against the `sof-js` reference implementation.
```json
{
"resources": [
{
"resourceType": "Patient",
"id": "pt1",
"name": [
{ "family": "F1", "given": ["G1a", "G1b"] },
{ "family": "F2" }
]
},
{
"resourceType": "Patient",
"id": "pt2"
}
],
"tests": [
{
"title": "forEach inside forEachOrNull (nested via select)",
"tags": ["shareable"],
"view": {
"resource": "Patient",
"status": "active",
"select": [
{ "column": [{ "name": "id", "path": "id", "type": "id" }] },
{
"forEachOrNull": "name",
"select": [
{ "column": [{ "name": "family", "path": "family", "type": "string" }] },
{
"forEach": "given",
"column": [{ "name": "given", "path": "$this", "type": "string" }]
}
]
}
]
},
"expect": [
{ "id": "pt1", "family": "F1", "given": "G1a" },
{ "id": "pt1", "family": "F1", "given": "G1b" }
]
}
]
}
```
For contrast, the existing "forEachOrNull & unionAll on the same level" case keeps a null row for the resource with no nested items, whereas this `select` case drops it entirely. That difference is the behaviour the new test pins down.
Contributor guide
No contributing guide indexed for this repository
Research direction
Add the self-contained conformance case to tests/foreach.json, alongside the existing forEach and forEachOrNull cases. Check the expected rows against the sof-js reference behavior, ensuring the nested select produces only the two pt1 rows and drops the empty branches as described.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100