mirror of https://github.com/Fabio286/antares.git
fix: select of table type stuck when editing an unknown type
This commit is contained in:
parent
6decba316c
commit
e8447e5655
|
@ -85,12 +85,9 @@ export interface TableInfos {
|
||||||
name: string;
|
name: string;
|
||||||
type: string;
|
type: string;
|
||||||
rows: number;
|
rows: number;
|
||||||
created: Date;
|
|
||||||
updated: Date;
|
|
||||||
engine: string;
|
engine: string;
|
||||||
comment: string;
|
comment: string;
|
||||||
size: number | false;
|
size: number | false;
|
||||||
autoIncrement: number;
|
|
||||||
collation: string;
|
collation: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -254,25 +254,15 @@ export class MySQLClient extends AntaresCore {
|
||||||
async getStructure (schemas: Set<string>) {
|
async getStructure (schemas: Set<string>) {
|
||||||
/* eslint-disable camelcase */
|
/* eslint-disable camelcase */
|
||||||
interface ShowTableResult {
|
interface ShowTableResult {
|
||||||
Db?: string;
|
TABLE_SCHEMA?: string;
|
||||||
Name: string;
|
TABLE_NAME: string;
|
||||||
Engine: string;
|
TABLE_TYPE: string;
|
||||||
Version: number;
|
TABLE_ROWS: number;
|
||||||
Row_format: string;
|
ENGINE: string;
|
||||||
Rows: number;
|
DATA_LENGTH: number;
|
||||||
Avg_row_length: number;
|
INDEX_LENGTH: number;
|
||||||
Data_length: number;
|
TABLE_COLLATION: string;
|
||||||
Max_data_length: number;
|
TABLE_COMMENT: string;
|
||||||
Index_length: number;
|
|
||||||
Data_free: number;
|
|
||||||
Auto_increment: number;
|
|
||||||
Create_time: Date;
|
|
||||||
Update_time: Date;
|
|
||||||
Check_time?: number;
|
|
||||||
Collation: string;
|
|
||||||
Checksum?: number;
|
|
||||||
Create_options: string;
|
|
||||||
Comment: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ShowTriggersResult {
|
interface ShowTriggersResult {
|
||||||
|
@ -309,10 +299,24 @@ export class MySQLClient extends AntaresCore {
|
||||||
for (const db of filteredDatabases) {
|
for (const db of filteredDatabases) {
|
||||||
if (!schemas.has(db.Database)) continue;
|
if (!schemas.has(db.Database)) continue;
|
||||||
|
|
||||||
let { rows: tables } = await this.raw<antares.QueryResult<ShowTableResult>>(`SHOW TABLE STATUS FROM \`${db.Database}\``);
|
let { rows: tables } = await this.raw<antares.QueryResult<ShowTableResult>>(`
|
||||||
|
SELECT
|
||||||
|
TABLE_NAME,
|
||||||
|
TABLE_TYPE,
|
||||||
|
ENGINE,
|
||||||
|
DATA_LENGTH,
|
||||||
|
INDEX_LENGTH,
|
||||||
|
TABLE_COMMENT,
|
||||||
|
TABLE_COLLATION,
|
||||||
|
CREATE_TIME,
|
||||||
|
UPDATE_TIME
|
||||||
|
FROM information_schema.TABLES
|
||||||
|
WHERE TABLE_SCHEMA = "${db.Database}"
|
||||||
|
`);
|
||||||
|
|
||||||
if (tables.length) {
|
if (tables.length) {
|
||||||
tables = tables.map(table => {
|
tables = tables.map(table => {
|
||||||
table.Db = db.Database;
|
table.TABLE_SCHEMA = db.Database;
|
||||||
return table;
|
return table;
|
||||||
});
|
});
|
||||||
tablesArr.push(...tables);
|
tablesArr.push(...tables);
|
||||||
|
@ -331,9 +335,9 @@ export class MySQLClient extends AntaresCore {
|
||||||
return filteredDatabases.map(db => {
|
return filteredDatabases.map(db => {
|
||||||
if (schemas.has(db.Database)) {
|
if (schemas.has(db.Database)) {
|
||||||
// TABLES
|
// TABLES
|
||||||
const remappedTables: antares.TableInfos[] = tablesArr.filter(table => table.Db === db.Database).map(table => {
|
const remappedTables: antares.TableInfos[] = tablesArr.filter(table => table.TABLE_SCHEMA === db.Database).map(table => {
|
||||||
let tableType;
|
let tableType;
|
||||||
switch (table.Comment) {
|
switch (table.TABLE_TYPE) {
|
||||||
case 'VIEW':
|
case 'VIEW':
|
||||||
tableType = 'view';
|
tableType = 'view';
|
||||||
break;
|
break;
|
||||||
|
@ -342,20 +346,17 @@ export class MySQLClient extends AntaresCore {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const tableSize = Number(table.Data_length) + Number(table.Index_length);
|
const tableSize = Number(table.DATA_LENGTH) + Number(table.INDEX_LENGTH);
|
||||||
schemaSize += tableSize;
|
schemaSize += tableSize;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: table.Name,
|
name: table.TABLE_NAME,
|
||||||
type: tableType,
|
type: tableType,
|
||||||
rows: table.Rows,
|
rows: table.TABLE_ROWS,
|
||||||
created: table.Create_time,
|
engine: table.ENGINE,
|
||||||
updated: table.Update_time,
|
comment: table.TABLE_COMMENT,
|
||||||
engine: table.Engine,
|
|
||||||
comment: table.Comment,
|
|
||||||
size: tableSize,
|
size: tableSize,
|
||||||
autoIncrement: table.Auto_increment,
|
collation: table.TABLE_COLLATION
|
||||||
collation: table.Collation
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -410,7 +410,7 @@ const types = computed(() => {
|
||||||
const types = [...props.dataTypes];
|
const types = [...props.dataTypes];
|
||||||
if (!isInDataTypes.value)
|
if (!isInDataTypes.value)
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
(types as any).unshift({ name: props.row });
|
(types as any).unshift({ name: props.row.type });
|
||||||
|
|
||||||
return types;
|
return types;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue