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:
@@ -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:]]
|
||||
|
||||
Reference in New Issue
Block a user