From e692dc90959ed09b311ac6edc570dab08f6c14e4 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 3bb98348957dd978ff63f965508f220cda9d96cd 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 cb90b872f56fc1b66dd7b5bb5b6a85e177030651 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 740c5fd9f1..a274fb24f0 100644 --- a/packages/client/src/components/app/forms/Form.svelte +++ b/packages/client/src/components/app/forms/Form.svelte @@ -80,7 +80,7 @@ } const fetchTable = async dataSource => { - if (dataSource?.tableId) { + if (dataSource?.tableId && dataSource?.type !== "query") { try { table = await API.fetchTableDefinition(dataSource.tableId) } catch (error) {