Skip to content

Commit 6b92599

Browse files
committedAug 17, 2021
fix(populate): handle populating subdoc array virtual with sort
Fix #10552
1 parent 283d43f commit 6b92599

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎lib/helpers/populate/assignRawDocsToIdStructure.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ function assignRawDocsToIdStructure(rawIds, resultDocs, resultOrder, options, re
6969
if (recursed) {
7070
if (doc) {
7171
if (sorting) {
72-
newOrder[resultOrder[sid]] = doc;
72+
const _resultOrder = resultOrder[sid];
73+
if (Array.isArray(_resultOrder) && Array.isArray(doc) && _resultOrder.length === doc.length) {
74+
newOrder.push(doc);
75+
} else {
76+
newOrder[_resultOrder] = doc;
77+
}
7378
} else {
7479
newOrder.push(doc);
7580
}

0 commit comments

Comments
 (0)
Please sign in to comment.