From 86f50521d05da0afdc9506d74e6ab007e2ae0a84 Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Mon, 28 Apr 2025 11:03:18 +0200 Subject: [PATCH] fix(MySQL): handle absence of CHECK_CONSTRAINTS table, fixes #981 --- src/main/libs/clients/MySQLClient.ts | 7 +- .../components/WorkspaceTabPropsTable.vue | 96 +++++++++++++------ 2 files changed, 75 insertions(+), 28 deletions(-) diff --git a/src/main/libs/clients/MySQLClient.ts b/src/main/libs/clients/MySQLClient.ts index b2b49f83..92ac0e11 100644 --- a/src/main/libs/clients/MySQLClient.ts +++ b/src/main/libs/clients/MySQLClient.ts @@ -696,7 +696,12 @@ export class MySQLClient extends BaseClient { return rows.length ? rows[0].count : 0; } - async getTableChecks ({ schema, table }: { schema: string; table: string }): Promise { + async getTableChecks ({ schema, table }: { schema: string; table: string }): Promise { + const { rows: checkTableExists } = await this.raw('SELECT table_name FROM information_schema.tables WHERE table_schema = "information_schema" AND table_name = "CHECK_CONSTRAINTS"'); + + if (!checkTableExists.length)// check if CHECK_CONSTRAINTS table exists + return false; + const { rows } = await this.raw(` SELECT CONSTRAINT_NAME as name, diff --git a/src/renderer/components/WorkspaceTabPropsTable.vue b/src/renderer/components/WorkspaceTabPropsTable.vue index 32ea29db..97db3d68 100644 --- a/src/renderer/components/WorkspaceTabPropsTable.vue +++ b/src/renderer/components/WorkspaceTabPropsTable.vue @@ -73,7 +73,7 @@ {{ t('database.foreignKeys') }}