value: compare field values in FieldValueIndex::containedIn

containedIn() only checked that the other index declared the same field
keys, never that they held the same values, contradicting its documented
contract of containment "with the same value".

Dht::query() uses containedIn() to deduplicate projected results. Because
every result of a given query shares the same projection schema, any two
results compared equal: the first one suppressed all the later ones, and the
"lesser" branch even erased the already reported result. A query selecting a
field therefore reported a single value regardless of how many matched.

Compare the FieldValue as well, and add a regression covering distinct
values, equal indexes and a narrower projection contained in a wider one.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Cyrille BéraudandCopilot authored and Adrien Beraud committed 2026-10-26 09:21:10 -04:00
1 parent 34eb86a119
commit bf8e3ea251
3 files changed
+34 -1

No files matched your search

+1 -1
View File
@@ -397,7 +397,7 @@ FieldValueIndex::containedIn(const FieldValueIndex& other) const
return false;
for (const auto& field : index) {
auto other_field = other.index.find(field.first);
if (other_field == other.index.end())
if (other_field == other.index.end() or not (field.second == other_field->second))
return false;
}
return true;