From 84593b8ff19785d3000ca75cff24311f3e5963c6 Mon Sep 17 00:00:00 2001 From: SuperGoo Date: Thu, 8 Aug 2024 12:16:39 +0800 Subject: [PATCH] fix: quote table name when get mysql table define --- .../database/src/query-interface/mysql-query-interface.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/core/database/src/query-interface/mysql-query-interface.ts b/packages/core/database/src/query-interface/mysql-query-interface.ts index c697ead01f..d4475cb753 100644 --- a/packages/core/database/src/query-interface/mysql-query-interface.ts +++ b/packages/core/database/src/query-interface/mysql-query-interface.ts @@ -91,7 +91,11 @@ export default class MysqlQueryInterface extends QueryInterface { async showTableDefinition(tableInfo: TableInfo): Promise { const { tableName } = tableInfo; - const sql = `SHOW CREATE TABLE ${tableName}`; + //nint quote table name for it may be special word like group + let newTableName = tableName; + if (!tableName.startsWith('`')) newTableName = this.db.utils.quoteTable(tableName); + const sql = `SHOW CREATE TABLE ${newTableName}`; + //const sql = `SHOW CREATE TABLE ${tableName}`; const results = await this.db.sequelize.query(sql, { type: 'SELECT' });