mirror of
https://github.com/Fabio286/antares.git
synced 2025-02-15 11:10:43 +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('*')
|
.select('*')
|
||||||
.schema('information_schema')
|
.schema('information_schema')
|
||||||
.from('COLUMNS')
|
.from('COLUMNS')
|
||||||
.where({ TABLE_SCHEMA: `= '${this._schema || schema}'`, TABLE_NAME: `= '${table}'` })
|
.where({ TABLE_SCHEMA: `= '${schema}'`, TABLE_NAME: `= '${table}'` })
|
||||||
.orderBy({ ORDINAL_POSITION: 'ASC' })
|
.orderBy({ ORDINAL_POSITION: 'ASC' })
|
||||||
.run();
|
.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 => {
|
const remappedFields = fields.map(row => {
|
||||||
if (!row['Create Table']) return false;
|
if (!row['Create Table']) return false;
|
||||||
|
@ -147,11 +147,7 @@
|
|||||||
:connection="connection"
|
:connection="connection"
|
||||||
:scheduler="workspace.breadcrumbs.scheduler"
|
:scheduler="workspace.breadcrumbs.scheduler"
|
||||||
/> -->
|
/> -->
|
||||||
<div
|
<template v-for="tab of workspace.tabs">
|
||||||
v-for="tab of workspace.tabs"
|
|
||||||
:key="tab.uid"
|
|
||||||
class="column col-12"
|
|
||||||
>
|
|
||||||
<WorkspaceQueryTab
|
<WorkspaceQueryTab
|
||||||
v-if="tab.type==='query'"
|
v-if="tab.type==='query'"
|
||||||
:key="tab.uid"
|
:key="tab.uid"
|
||||||
@ -161,13 +157,13 @@
|
|||||||
/>
|
/>
|
||||||
<WorkspaceTableTab
|
<WorkspaceTableTab
|
||||||
v-else-if="tab.type==='temp-data'"
|
v-else-if="tab.type==='temp-data'"
|
||||||
v-show="selectedTab === tab.uid"
|
:key="tab.uid"
|
||||||
:is-selected="selectedTab === tab.uid"
|
|
||||||
:connection="connection"
|
:connection="connection"
|
||||||
|
:is-selected="selectedTab === tab.uid"
|
||||||
:table="tab.table"
|
:table="tab.table"
|
||||||
:schema="tab.schema"
|
:schema="tab.schema"
|
||||||
/>
|
/>
|
||||||
</div>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<WorkspaceEditConnectionPanel v-else :connection="connection" />
|
<WorkspaceEditConnectionPanel v-else :connection="connection" />
|
||||||
<ModalProcessesList
|
<ModalProcessesList
|
||||||
|
@ -282,7 +282,7 @@ export default {
|
|||||||
},
|
},
|
||||||
selectTable ({ schema, table }) {
|
selectTable ({ schema, table }) {
|
||||||
this.setBreadcrumbs({ schema, [table.type]: table.name });
|
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' });
|
this.newTab({ uid: this.connection.uid, table: table.name, schema: this.database.name, type: 'temp-data' });
|
||||||
},
|
},
|
||||||
showSchemaContext (event, schema) {
|
showSchemaContext (event, schema) {
|
||||||
|
@ -156,6 +156,9 @@ export default {
|
|||||||
workspace () {
|
workspace () {
|
||||||
return this.getWorkspace(this.connection.uid);
|
return this.getWorkspace(this.connection.uid);
|
||||||
},
|
},
|
||||||
|
schema () {
|
||||||
|
return this.workspace.breadcrumbs.schema;
|
||||||
|
},
|
||||||
isWorkspaceSelected () {
|
isWorkspaceSelected () {
|
||||||
return this.workspace.uid === this.selectedWorkspace;
|
return this.workspace.uid === this.selectedWorkspace;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<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 column col-12">
|
||||||
<div class="workspace-query-runner-footer">
|
<div class="workspace-query-runner-footer">
|
||||||
<div class="workspace-query-buttons">
|
<div class="workspace-query-buttons">
|
||||||
@ -181,7 +181,9 @@ export default {
|
|||||||
mixins: [tableTabs],
|
mixins: [tableTabs],
|
||||||
props: {
|
props: {
|
||||||
connection: Object,
|
connection: Object,
|
||||||
table: String
|
isSelected: Boolean,
|
||||||
|
table: String,
|
||||||
|
schema: String
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
@ -208,9 +210,6 @@ export default {
|
|||||||
workspace () {
|
workspace () {
|
||||||
return this.getWorkspace(this.connection.uid);
|
return this.getWorkspace(this.connection.uid);
|
||||||
},
|
},
|
||||||
isSelected () {
|
|
||||||
return this.workspace.selected_tab === 'data' && this.workspace.uid === this.selectedWorkspace;
|
|
||||||
},
|
|
||||||
isTable () {
|
isTable () {
|
||||||
return !!this.workspace.breadcrumbs.table;
|
return !!this.workspace.breadcrumbs.table;
|
||||||
},
|
},
|
||||||
@ -282,7 +281,7 @@ export default {
|
|||||||
const params = {
|
const params = {
|
||||||
uid: this.connection.uid,
|
uid: this.connection.uid,
|
||||||
schema: this.schema,
|
schema: this.schema,
|
||||||
table: this.workspace.breadcrumbs.table || this.workspace.breadcrumbs.view,
|
table: this.table,
|
||||||
limit: this.limit,
|
limit: this.limit,
|
||||||
page: this.page,
|
page: this.page,
|
||||||
sortParams
|
sortParams
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
import Tables from '@/ipc-api/Tables';
|
import Tables from '@/ipc-api/Tables';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
computed: {
|
|
||||||
schema () {
|
|
||||||
return this.workspace.breadcrumbs.schema;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
async updateField (payload) {
|
async updateField (payload) {
|
||||||
this.isQuering = true;
|
this.isQuering = true;
|
||||||
|
@ -480,7 +480,7 @@ export default {
|
|||||||
const tempTabs = workspaceTabs ? workspaceTabs.tabs.filter(tab => tab.type === 'temp-data') : false;
|
const tempTabs = workspaceTabs ? workspaceTabs.tabs.filter(tab => tab.type === 'temp-data') : false;
|
||||||
if (tempTabs) {
|
if (tempTabs) {
|
||||||
for (const tab of 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