1
0
Fork 0
mirror of synced 2024-07-02 13:01:09 +12:00

Merge pull request #5389 from Budibase/fix-query-error

Fix query error
This commit is contained in:
Andrew Kingston 2022-04-13 14:12:47 +01:00 committed by GitHub
commit 4aa0b1533e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 6 deletions

View file

@ -52,7 +52,6 @@
.map(query => ({ .map(query => ({
label: query.name, label: query.name,
name: query.name, name: query.name,
tableId: query._id,
...query, ...query,
type: "query", type: "query",
})) }))

View file

@ -15,16 +15,14 @@
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
$: datasource = getDatasourceForProvider($currentAsset, componentInstance) $: datasource = getDatasourceForProvider($currentAsset, componentInstance)
$: schema = getSchemaForDatasource($currentAsset, datasource, { $: schema = getSchemaForDatasource($currentAsset, datasource).schema
searchableSchema: true,
}).schema
$: options = getOptions(datasource, schema || {}) $: options = getOptions(datasource, schema || {})
$: boundValue = getSelectedOption(value, options) $: boundValue = getSelectedOption(value, options)
function getOptions(ds, dsSchema) { function getOptions(ds, dsSchema) {
let base = Object.values(dsSchema) let base = Object.values(dsSchema)
if (!ds?.tableId) { if (!ds?.tableId) {
return base return base.map(field => field.name)
} }
const currentTable = $tables.list.find(table => table._id === ds.tableId) const currentTable = $tables.list.find(table => table._id === ds.tableId)
return getFields(base, { allowLinks: currentTable?.sql }).map( return getFields(base, { allowLinks: currentTable?.sql }).map(

View file

@ -76,7 +76,7 @@
} }
const fetchTable = async dataSource => { const fetchTable = async dataSource => {
if (dataSource?.tableId) { if (dataSource?.tableId && dataSource?.type !== "query") {
try { try {
table = await API.fetchTableDefinition(dataSource.tableId) table = await API.fetchTableDefinition(dataSource.tableId)
} catch (error) { } catch (error) {