From 725dc3ce5be2ad442dd9f49cf251639230e77301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=BCttner?= Date: Tue, 6 Aug 2024 14:05:12 +0200 Subject: [PATCH] Fix M2A query regression from #23181 (#23195) --- .../database/get-ast-from-query/lib/parse-fields.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/api/src/database/get-ast-from-query/lib/parse-fields.ts b/api/src/database/get-ast-from-query/lib/parse-fields.ts index f3051cf406..4d8be36e09 100644 --- a/api/src/database/get-ast-from-query/lib/parse-fields.ts +++ b/api/src/database/get-ast-from-query/lib/parse-fields.ts @@ -137,8 +137,14 @@ export async function parseFields( } if (name.includes(':')) { - const [key, scope] = name.split(':'); - relationalStructure[key!] = { [scope!]: [] }; + const [key, scope] = name.split(':') as [string, string]; + + if (key in relationalStructure === false) { + relationalStructure[key] = { [scope]: [] }; + } else if (scope in (relationalStructure[key] as CollectionScope) === false) { + (relationalStructure[key] as CollectionScope)[scope] = []; + } + continue; }