fix(core): Keep order of nested relations during hydration (#2864) #2865
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Relations could get out of sync during entity hydration. See #2864 for a detailed description and example.
I moved
mergeDeep
out of the service to make testing easier. I think adding an e2e Test for this does not make sense as it would be very hard to control the result order of the hydration database query. So I decided to unit testmergeDeep
instead.The only actual change is:
changed to:
I don't see a case where calling mergeDeep would not work because mergeDeep still executes the same logic inside the recursion by iterating using
for (const [key, value] of Object.entries(b))
and assigning the values using(a as any)[key] = b[key];
, event ifa
andb
do not contain entities.Breaking changes
None
Checklist
📌 Always:
👍 Most of the time: