From 6a0e46a0a685a53ff1aab54bd533288efd664d39 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 19 Mar 2024 16:24:15 +0000 Subject: [PATCH] Proper fix, making sure that low level handling of JSON column types correctly handles aliasing. --- packages/server/src/integrations/base/sql.ts | 9 ++++++--- .../utilities/rowProcessor/bbReferenceProcessor.ts | 12 ++---------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/packages/server/src/integrations/base/sql.ts b/packages/server/src/integrations/base/sql.ts index 8342c45fd7..f5e7812861 100644 --- a/packages/server/src/integrations/base/sql.ts +++ b/packages/server/src/integrations/base/sql.ts @@ -705,10 +705,13 @@ class SqlQueryBuilder extends SqlTableQueryBuilder { if (!this._isJsonColumn(field)) { continue } - const fullName = `${table.name}.${name}` for (let row of results) { - if (typeof row[fullName] === "string") { - row[fullName] = JSON.parse(row[fullName]) + const columnNames = Object.keys(row) + const fullColumnName = columnNames.find( + column => column.includes(`.${name}`) || column === name + ) + if (fullColumnName && typeof row[fullColumnName] === "string") { + row[fullColumnName] = JSON.parse(row[fullColumnName]) } if (typeof row[name] === "string") { row[name] = JSON.parse(row[name]) diff --git a/packages/server/src/utilities/rowProcessor/bbReferenceProcessor.ts b/packages/server/src/utilities/rowProcessor/bbReferenceProcessor.ts index a51ac32da7..c7b8998bad 100644 --- a/packages/server/src/utilities/rowProcessor/bbReferenceProcessor.ts +++ b/packages/server/src/utilities/rowProcessor/bbReferenceProcessor.ts @@ -68,16 +68,8 @@ export async function processOutputBBReferences( return value || undefined } - let ids: string[] = [] - if (typeof value === "string") { - try { - ids = JSON.parse(value) - } catch (err) { - ids = value.split(",").filter(id => !!id) - } - } else if (Array.isArray(value)) { - ids = value - } + const ids = + typeof value === "string" ? value.split(",").filter(id => !!id) : value switch (subtype) { case FieldSubtype.USER: