fix: quote table name when get mysql table define

This commit is contained in:
SuperGoo 2024-08-08 12:16:39 +08:00
parent d37c71aaed
commit 84593b8ff1

View File

@ -91,7 +91,11 @@ export default class MysqlQueryInterface extends QueryInterface {
async showTableDefinition(tableInfo: TableInfo): Promise<any> {
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' });