Files
releases/test/cases/testdata/partialiter
Torin Sandall 87c3f0774b topdown: Deduplicate when iterating partial rules
This commit fixes an old issue in the evaluator whereby duplicate keys
could be returned when iterating over documents generated by partial
rules. Specifically, because the code path to evaluate partial sets
and partial objects differs when elements are accessed individually
versus in aggregate (e.g., `p[x] = y` vs `p = q; q[x] = y`) callers
could see different results in some cases. For example:

```
[[x,y] | p[x] = y]

[[x, y] | p = q; q[x] = y]
```

In this case, query 1 and 2 could produce different results. For both
partial sets and objects, the result may contain duplicate values. In
addition, for partial objects, the first query may succeed, while the
second query may generate a conflict error if the same key was mapped
more than one value.

The fix simply keeps track of the values that have been generated
while evaluating the rules and performs deduplication/conflict
checking just like in the aggregate case. When duplicates are
encountered, the evaluator will emit Duplicate events to indicate that
evaluation is not continuing.

Fixes #429

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2021-01-19 15:11:47 -05:00
..