From 8d825e37a42dd13d051460598f4e7b1b32482273 Mon Sep 17 00:00:00 2001 From: "Visal .In" Date: Thu, 27 Jul 2023 18:42:01 +0700 Subject: [PATCH] fix: incorrect query for table structure --- src/drivers/common/MySQLCommonInterface.ts | 7 +++++-- src/drivers/common/SQLCommonInterface.ts | 5 ++++- .../screens/DatabaseScreen/SqlTableSchemaTab/index.tsx | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/drivers/common/MySQLCommonInterface.ts b/src/drivers/common/MySQLCommonInterface.ts index dc14ab5..9d9ec21 100644 --- a/src/drivers/common/MySQLCommonInterface.ts +++ b/src/drivers/common/MySQLCommonInterface.ts @@ -259,7 +259,10 @@ export default class MySQLCommonInterface extends SQLCommonInterface { ); } - async getTableSchema(table: string): Promise { + async getTableSchema( + database: string, + table: string + ): Promise { const response = await this.runner.execute( [ { @@ -279,7 +282,7 @@ export default class MySQLCommonInterface extends SQLCommonInterface { 'COLUMN_TYPE' ) .where({ - table_schema: this.currentDatabaseName, + table_schema: database, table_name: table, }) .toRawSQL(), diff --git a/src/drivers/common/SQLCommonInterface.ts b/src/drivers/common/SQLCommonInterface.ts index 59c343e..a28b5b5 100644 --- a/src/drivers/common/SQLCommonInterface.ts +++ b/src/drivers/common/SQLCommonInterface.ts @@ -2,6 +2,9 @@ import { DatabaseSchemas, TableDefinitionSchema } from 'types/SqlSchema'; export default abstract class SQLCommonInterface { abstract getSchema(): Promise; - abstract getTableSchema(table: string): Promise; + abstract getTableSchema( + database: string, + table: string + ): Promise; abstract switchDatabase(database: string): Promise; } diff --git a/src/renderer/screens/DatabaseScreen/SqlTableSchemaTab/index.tsx b/src/renderer/screens/DatabaseScreen/SqlTableSchemaTab/index.tsx index c1ee372..24ee68d 100644 --- a/src/renderer/screens/DatabaseScreen/SqlTableSchemaTab/index.tsx +++ b/src/renderer/screens/DatabaseScreen/SqlTableSchemaTab/index.tsx @@ -24,8 +24,8 @@ export default function SqlTableSchemaTab({ ); useEffect(() => { - common.getTableSchema(table).then(setDefinition).catch(); - }, [common]); + common.getTableSchema(database, table).then(setDefinition).catch(); + }, [database, common]); useEffect(() => { setTabData(tabKey, { type: 'table-schema', database, table });