Fixing an issue shown in #9602 where the schema type will revert each time you re-run a query, this will hold any previously selected schema information in the query.

This commit is contained in:
mike12345567 2023-02-28 19:27:59 +00:00
parent db28c5006c
commit 5882f2b468
1 changed files with 11 additions and 1 deletions

View File

@ -35,6 +35,7 @@
let parameters let parameters
let data = [] let data = []
let saveId let saveId
let currentTab = "JSON"
$: datasource = $datasources.list.find(ds => ds._id === query.datasourceId) $: datasource = $datasources.list.find(ds => ds._id === query.datasourceId)
$: query.schema = fieldsToSchema(fields) $: query.schema = fieldsToSchema(fields)
@ -84,7 +85,16 @@
return return
} }
data = response.rows data = response.rows
// need to merge fields that already exist/might have changed
if (fields) {
for (let key of Object.keys(response.schema)) {
if (fields[key]) {
response.schema[key] = fields[key]
}
}
}
fields = response.schema fields = response.schema
currentTab = "JSON"
notifications.success("Query executed successfully") notifications.success("Query executed successfully")
} catch (error) { } catch (error) {
notifications.error(`Query Error: ${error.message}`) notifications.error(`Query Error: ${error.message}`)
@ -205,7 +215,7 @@
</Body> </Body>
<section class="viewer"> <section class="viewer">
{#if data} {#if data}
<Tabs selected="JSON"> <Tabs bind:selected={currentTab}>
<Tab title="JSON"> <Tab title="JSON">
<JSONPreview data={data[0]} minHeight="120" /> <JSONPreview data={data[0]} minHeight="120" />
</Tab> </Tab>