From 1b96e712371a4993f1def3f6cc59cdc5ea9cdec1 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 30 Sep 2022 15:56:06 +0100 Subject: [PATCH] Fix generating datsource structure for components which have a setting of type table --- packages/builder/src/builderStore/dataBinding.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/builder/src/builderStore/dataBinding.js b/packages/builder/src/builderStore/dataBinding.js index ca36380077..7456ec5691 100644 --- a/packages/builder/src/builderStore/dataBinding.js +++ b/packages/builder/src/builderStore/dataBinding.js @@ -243,18 +243,18 @@ export const getDatasourceForProvider = (asset, component) => { return null } - // There are different types of setting which can be a datasource, for - // example an actual datasource object, or a table ID string. - // Convert the datasource setting into a proper datasource object so that - // we can use it properly - if (datasourceSetting.type === "table") { + // For legacy compatibility, we need to be able to handle datasources that are + // just strings. These are not generated any more, so could be removed in + // future. + // TODO: remove at some point + const datasource = component[datasourceSetting?.key] + if (typeof datasource === "string") { return { - tableId: component[datasourceSetting?.key], + tableId: datasource, type: "table", } - } else { - return component[datasourceSetting?.key] } + return datasource } /**