Skip to content

Commit 230773a

Browse files
authored
fix: incorrect query for table structure (#70)
1 parent 9514cd3 commit 230773a

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/drivers/common/MySQLCommonInterface.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,10 @@ export default class MySQLCommonInterface extends SQLCommonInterface {
259259
);
260260
}
261261

262-
async getTableSchema(table: string): Promise<TableDefinitionSchema> {
262+
async getTableSchema(
263+
database: string,
264+
table: string
265+
): Promise<TableDefinitionSchema> {
263266
const response = await this.runner.execute(
264267
[
265268
{
@@ -279,7 +282,7 @@ export default class MySQLCommonInterface extends SQLCommonInterface {
279282
'COLUMN_TYPE'
280283
)
281284
.where({
282-
table_schema: this.currentDatabaseName,
285+
table_schema: database,
283286
table_name: table,
284287
})
285288
.toRawSQL(),

src/drivers/common/SQLCommonInterface.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import { DatabaseSchemas, TableDefinitionSchema } from 'types/SqlSchema';
22

33
export default abstract class SQLCommonInterface {
44
abstract getSchema(): Promise<DatabaseSchemas>;
5-
abstract getTableSchema(table: string): Promise<TableDefinitionSchema>;
5+
abstract getTableSchema(
6+
database: string,
7+
table: string
8+
): Promise<TableDefinitionSchema>;
69
abstract switchDatabase(database: string): Promise<boolean>;
710
}

src/renderer/screens/DatabaseScreen/SqlTableSchemaTab/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export default function SqlTableSchemaTab({
2424
);
2525

2626
useEffect(() => {
27-
common.getTableSchema(table).then(setDefinition).catch();
28-
}, [common]);
27+
common.getTableSchema(database, table).then(setDefinition).catch();
28+
}, [database, common]);
2929

3030
useEffect(() => {
3131
setTabData(tabKey, { type: 'table-schema', database, table });

0 commit comments

Comments
 (0)