From 583fb7505e56f580fc90c26d200ac9c6ca5430c4 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 13 Dec 2024 11:21:24 +0100 Subject: [PATCH] Fix sqs views --- .../server/src/sdk/app/rows/search/internal/sqs.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/server/src/sdk/app/rows/search/internal/sqs.ts b/packages/server/src/sdk/app/rows/search/internal/sqs.ts index aa799390b8..6eb9bd913b 100644 --- a/packages/server/src/sdk/app/rows/search/internal/sqs.ts +++ b/packages/server/src/sdk/app/rows/search/internal/sqs.ts @@ -234,6 +234,17 @@ async function runSqlQuery( json.operation = Operation.COUNT } const processSQLQuery = async (json: EnrichedQueryJson) => { + const fields = json.resource?.fields + if (fields) { + const tableId = json.tableAliases?.[json.table._id!] ?? json.table._id! + for (const key of ["_id", "_rev", "tableId"]) { + const field = `${tableId}.${key}` + if (fields.includes(field)) { + continue + } + fields.push(field) + } + } const query = builder._query(json, { disableReturning: true, })