浏览代码

fix: 修复非法SQL拦截插件索引检测问题

获取数据库名称的实现有问题
Serenity 4 月之前
父节点
当前提交
cd0ed48e41

+ 2 - 10
mybatis-plus-jsqlparser-support/mybatis-plus-jsqlparser/src/main/java/com/baomidou/mybatisplus/extension/plugins/inner/IllegalSQLInnerInterceptor.java

@@ -231,17 +231,9 @@ public class IllegalSQLInnerInterceptor extends JsqlParserSupport implements Inn
         //是否使用索引
         boolean useIndexFlag = false;
         if (StringUtils.isNotBlank(columnName)) {
-            String tableInfo = table.getName();
             //表存在的索引
-            String dbName = null;
-            String tableName;
-            String[] tableArray = tableInfo.split("\\.");
-            if (tableArray.length == 1) {
-                tableName = tableArray[0];
-            } else {
-                dbName = tableArray[0];
-                tableName = tableArray[1];
-            }
+            String dbName = table.getSchemaName();
+            String tableName = table.getName();
             columnName = SqlParserUtils.removeWrapperSymbol(columnName);
             List<IndexInfo> indexInfos = getIndexInfos(dbName, tableName, connection);
             for (IndexInfo indexInfo : indexInfos) {