Pre Merge pull request !412 from yi-l-i-yi-li/master

This commit is contained in:
yi-l-i-yi-li 2022-12-12 05:48:28 +00:00 committed by Gitee
commit ad13ef3efd
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 3 additions and 2 deletions

View File

@ -13,7 +13,7 @@ public class SqlUtil
/**
* 定义常用的 sql关键字
*/
public static String SQL_REGEX = "select |insert |delete |update |drop |count |exec |chr |mid |master |truncate |char |and |declare ";
public static String SQL_REGEX = "select|insert|delete|update|drop|count|exec|chr |mid |master|truncate|char |and |declare";
/**
* 仅支持字母数字下划线空格逗号小数点支持多个字段排序

View File

@ -199,7 +199,6 @@ public class GenController extends BaseController
{
try
{
SqlUtil.filterKeyword(sql);
List<SQLStatement> sqlStatements = SQLUtils.parseStatements(sql, DbType.mysql);
List<String> tableNames = new ArrayList<>();
for (SQLStatement sqlStatement : sqlStatements)
@ -207,6 +206,8 @@ public class GenController extends BaseController
if (sqlStatement instanceof MySqlCreateTableStatement)
{
MySqlCreateTableStatement createTableStatement = (MySqlCreateTableStatement) sqlStatement;
// 关键字过滤
SqlUtil.filterKeyword(createTableStatement.toString());
if (genTableService.createTable(createTableStatement.toString()))
{
String tableName = createTableStatement.getTableName().replaceAll("`", "");