From 64b380a8a55beceb561ef635bec8bcba699bafde Mon Sep 17 00:00:00 2001 From: rijkvanzanten Date: Wed, 23 Sep 2020 17:07:53 -0400 Subject: [PATCH] Fix deep recursive m2o temp filtering --- api/src/database/run-ast.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/database/run-ast.ts b/api/src/database/run-ast.ts index f888295dbd..3dda776fdc 100644 --- a/api/src/database/run-ast.ts +++ b/api/src/database/run-ast.ts @@ -201,7 +201,7 @@ function removeTemporaryFields(rawItems: Item[], ast: AST | NestedCollectionAST) const item = fields.includes('*') ? rawItem : pick(rawItem, fields); for (const nestedCollection of nestedCollections) { - item[nestedCollection.fieldKey] = removeTemporaryFields(rawItem[nestedCollection.fieldKey], nestedCollection); + item[nestedCollection.fieldKey] = removeTemporaryFields(Array.isArray(rawItem[nestedCollection.fieldKey]) ? rawItem[nestedCollection.fieldKey] : [rawItem[nestedCollection.fieldKey]], nestedCollection); if (isM2O(nestedCollection)) { item[nestedCollection.fieldKey] = item[nestedCollection.fieldKey][0] || null;