From d6688d19143abeb01803dec0062a124cf814a3d5 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 25 Aug 2023 09:35:30 +0100 Subject: [PATCH] Use view name when generating bindings --- packages/builder/src/builderStore/dataBinding.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/builderStore/dataBinding.js b/packages/builder/src/builderStore/dataBinding.js index a0af5012c1..71d0a2d38a 100644 --- a/packages/builder/src/builderStore/dataBinding.js +++ b/packages/builder/src/builderStore/dataBinding.js @@ -350,12 +350,19 @@ const getProviderContextBindings = (asset, dataProviders) => { schema = info.schema table = info.table - // For JSON arrays, use the array name as the readable prefix. - // Otherwise use the table name + // Determine what to prefix bindings with if (datasource.type === "jsonarray") { + // For JSON arrays, use the array name as the readable prefix const split = datasource.label.split(".") readablePrefix = split[split.length - 1] + } else if (datasource.type === "viewV2") { + // For views, use the view name + const view = Object.values(table?.views || {}).find( + view => view.id === datasource.id + ) + readablePrefix = view?.name } else { + // Otherwise use the table name readablePrefix = info.table?.name } }