mirror of
https://github.com/Fabio286/antares.git
synced 2025-02-13 02:00:36 +01:00
refactor(core): better way to obtain schema
This commit is contained in:
parent
a87079cd17
commit
7488bc7a17
@ -335,11 +335,11 @@ export class MySQLClient extends AntaresCore {
|
||||
.select('*')
|
||||
.schema('information_schema')
|
||||
.from('COLUMNS')
|
||||
.where({ TABLE_SCHEMA: `= '${this._schema || schema}'`, TABLE_NAME: `= '${table}'` })
|
||||
.where({ TABLE_SCHEMA: `= '${schema}'`, TABLE_NAME: `= '${table}'` })
|
||||
.orderBy({ ORDINAL_POSITION: 'ASC' })
|
||||
.run();
|
||||
|
||||
const { rows: fields } = await this.raw(`SHOW CREATE TABLE \`${this._schema || schema}\`.\`${table}\``);
|
||||
const { rows: fields } = await this.raw(`SHOW CREATE TABLE \`${schema}\`.\`${table}\``);
|
||||
|
||||
const remappedFields = fields.map(row => {
|
||||
if (!row['Create Table']) return false;
|
||||
|
@ -147,11 +147,7 @@
|
||||
:connection="connection"
|
||||
:scheduler="workspace.breadcrumbs.scheduler"
|
||||
/> -->
|
||||
<div
|
||||
v-for="tab of workspace.tabs"
|
||||
:key="tab.uid"
|
||||
class="column col-12"
|
||||
>
|
||||
<template v-for="tab of workspace.tabs">
|
||||
<WorkspaceQueryTab
|
||||
v-if="tab.type==='query'"
|
||||
:key="tab.uid"
|
||||
@ -161,13 +157,13 @@
|
||||
/>
|
||||
<WorkspaceTableTab
|
||||
v-else-if="tab.type==='temp-data'"
|
||||
v-show="selectedTab === tab.uid"
|
||||
:is-selected="selectedTab === tab.uid"
|
||||
:key="tab.uid"
|
||||
:connection="connection"
|
||||
:is-selected="selectedTab === tab.uid"
|
||||
:table="tab.table"
|
||||
:schema="tab.schema"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<WorkspaceEditConnectionPanel v-else :connection="connection" />
|
||||
<ModalProcessesList
|
||||
|
@ -282,7 +282,7 @@ export default {
|
||||
},
|
||||
selectTable ({ schema, table }) {
|
||||
this.setBreadcrumbs({ schema, [table.type]: table.name });
|
||||
// TODO: open only if not present
|
||||
// TODO: open only if not already opened
|
||||
this.newTab({ uid: this.connection.uid, table: table.name, schema: this.database.name, type: 'temp-data' });
|
||||
},
|
||||
showSchemaContext (event, schema) {
|
||||
|
@ -156,6 +156,9 @@ export default {
|
||||
workspace () {
|
||||
return this.getWorkspace(this.connection.uid);
|
||||
},
|
||||
schema () {
|
||||
return this.workspace.breadcrumbs.schema;
|
||||
},
|
||||
isWorkspaceSelected () {
|
||||
return this.workspace.uid === this.selectedWorkspace;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div v-show="isSelected" class="workspace-query-tab column col-12 columns col-gapless p-0">
|
||||
<div v-show="isSelected" class="workspace-query-tab column col-12 columns col-gapless no-outline p-0">
|
||||
<div class="workspace-query-runner column col-12">
|
||||
<div class="workspace-query-runner-footer">
|
||||
<div class="workspace-query-buttons">
|
||||
@ -181,7 +181,9 @@ export default {
|
||||
mixins: [tableTabs],
|
||||
props: {
|
||||
connection: Object,
|
||||
table: String
|
||||
isSelected: Boolean,
|
||||
table: String,
|
||||
schema: String
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
@ -208,9 +210,6 @@ export default {
|
||||
workspace () {
|
||||
return this.getWorkspace(this.connection.uid);
|
||||
},
|
||||
isSelected () {
|
||||
return this.workspace.selected_tab === 'data' && this.workspace.uid === this.selectedWorkspace;
|
||||
},
|
||||
isTable () {
|
||||
return !!this.workspace.breadcrumbs.table;
|
||||
},
|
||||
@ -282,7 +281,7 @@ export default {
|
||||
const params = {
|
||||
uid: this.connection.uid,
|
||||
schema: this.schema,
|
||||
table: this.workspace.breadcrumbs.table || this.workspace.breadcrumbs.view,
|
||||
table: this.table,
|
||||
limit: this.limit,
|
||||
page: this.page,
|
||||
sortParams
|
||||
|
@ -1,11 +1,6 @@
|
||||
import Tables from '@/ipc-api/Tables';
|
||||
|
||||
export default {
|
||||
computed: {
|
||||
schema () {
|
||||
return this.workspace.breadcrumbs.schema;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async updateField (payload) {
|
||||
this.isQuering = true;
|
||||
|
@ -480,7 +480,7 @@ export default {
|
||||
const tempTabs = workspaceTabs ? workspaceTabs.tabs.filter(tab => tab.type === 'temp-data') : false;
|
||||
if (tempTabs) {
|
||||
for (const tab of tempTabs)
|
||||
commit('REMOVE_TAB', { uid, tab: tab.uid });
|
||||
commit('REMOVE_TAB', { uid, tab: tab.uid });// TODO: replace instead remove
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user