Make target ids unique when reading related fields

The result is converted into a dict based on the id so we must ensure that the
ids read are unique in case the same id appears after size limit.

Closes #14304
This commit is contained in:
Cédric Krier
2025-10-21 12:07:40 +02:00
parent 47efd4dba1
commit a735ea7a2b
+2
View File
@@ -1317,6 +1317,8 @@ class ModelSQL(ModelStorage):
if value is not None:
add(value)
related_read_limit = transaction.context.get('related_read_limit')
# use dict keys to make target ids unique but preserving the order
target_ids = list(dict.fromkeys(target_ids).keys())
rows = Target.read(target_ids[:related_read_limit], fields)
if related_read_limit is not None:
rows += [{'id': i} for i in target_ids[related_read_limit:]]