From ff986c7f85a6d2e102e12907cbeb0eb584035b5e Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 12 Apr 2022 16:27:14 +0100 Subject: [PATCH 1/3] Use the readable schema when generating search field options --- .../PropertiesPanel/PropertyControls/SearchFieldSelect.svelte | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/SearchFieldSelect.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/SearchFieldSelect.svelte index b3387fdd05..e609426b1e 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/SearchFieldSelect.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/SearchFieldSelect.svelte @@ -15,9 +15,7 @@ const dispatch = createEventDispatcher() $: datasource = getDatasourceForProvider($currentAsset, componentInstance) - $: schema = getSchemaForDatasource($currentAsset, datasource, { - searchableSchema: true, - }).schema + $: schema = getSchemaForDatasource($currentAsset, datasource).schema $: options = getOptions(datasource, schema || {}) $: boundValue = getSelectedOption(value, options) From 6cf8f19daf41c9c2bb974f1b2a09c529f10fcc34 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 12 Apr 2022 16:58:26 +0100 Subject: [PATCH 2/3] Remove table ID from custom queries to fix 500 errors when trying to fetch a table definition and passing up a query ID, and fix issue with search fields when no table ID exists --- .../PropertiesPanel/PropertyControls/DataSourceSelect.svelte | 1 - .../PropertiesPanel/PropertyControls/SearchFieldSelect.svelte | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/DataSourceSelect.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/DataSourceSelect.svelte index 73554b45db..1e19508744 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/DataSourceSelect.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/DataSourceSelect.svelte @@ -52,7 +52,6 @@ .map(query => ({ label: query.name, name: query.name, - tableId: query._id, ...query, type: "query", })) diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/SearchFieldSelect.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/SearchFieldSelect.svelte index e609426b1e..41906d3ba1 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/SearchFieldSelect.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/SearchFieldSelect.svelte @@ -22,7 +22,7 @@ function getOptions(ds, dsSchema) { let base = Object.values(dsSchema) if (!ds?.tableId) { - return base + return base.map(field => field.name) } const currentTable = $tables.list.find(table => table._id === ds.tableId) return getFields(base, { allowLinks: currentTable?.sql }).map( From 543578051e30b32084ebe35fa5f3a18245206531 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 13 Apr 2022 10:27:32 +0100 Subject: [PATCH 3/3] Ensure existing invalid datasource definitions are also fixed by checking data source type before fetching table definitions --- packages/client/src/components/app/forms/Form.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/src/components/app/forms/Form.svelte b/packages/client/src/components/app/forms/Form.svelte index 8e2e0b2510..8de729ae0a 100644 --- a/packages/client/src/components/app/forms/Form.svelte +++ b/packages/client/src/components/app/forms/Form.svelte @@ -76,7 +76,7 @@ } const fetchTable = async dataSource => { - if (dataSource?.tableId) { + if (dataSource?.tableId && dataSource?.type !== "query") { try { table = await API.fetchTableDefinition(dataSource.tableId) } catch (error) {