当前使用版本(必填,否则不予处理)

3.1

该问题是如何引起的?(确定最新版也有问题再提!!!)

添加了IllegalSQLInterceptor。 在使用中发现deleted_flag这类字段也会判断索引。还有类似的像性别这类字段不需要加索引吧。

重现步骤(如果有就写完整)

报错信息

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: 非法SQL,SQL未使用到索引, table:admin_user_role, columnName:deleted_flag

Comment From: willenfoo

MyBatis-Plus IllegalSQLInterceptor提示deleted_flag未使用索引

Comment From: willenfoo

你可以加上 @SqlParser(filter = true) 注解,跳过该方法验证

Comment From: zhusaidong

目前只支持注解在 mapper 的方法上

那岂不是所以mapper方法都要加

加在mapper方法上意味着跳过整条sql的解析,那这个IllegalSQLInterceptor的意义是什么。

Comment From: willenfoo

IllegalSQLInterceptor的意义,自己去阅读代码里面的注释

Comment From: zhusaidong

读了啊,“拦截掉垃圾SQL语句”。 我的问题是如果使用 @sqlparser(filter = true) 跳过sql验证,那还我使用IllegalSQLInterceptor的干嘛。

Comment From: jack-yu-matrix

这个interceptor 还不是很成熟

Comment From: jack-yu-matrix

这个 interceptor 鼓励开发人员只进行单表查询,然后组装数据

Comment From: dongbaibai

deleted_flag字段有索引,那肯定是你表设计的时候将这个列添加了索引; IllegalSQLInterceptor会在初始化表的索引信息的时候,连接数据库去检查;

不管这个表设计的问题,如果你要排除的话就用SqlParser

Comment From: willenfoo

@sqlparser(filter = true) 跳过sql验证,那还我使用IllegalSQLInterceptor的干嘛。 是为了让你更加灵活的控制

Comment From: willenfoo

IllegalSQLInterceptor的设计初衷,是所有查询SQL必须使用索引,麻得出现很多垃圾SQL,有些后台统计的SQL,使用@sqlparser(filter = true) 即可

Comment From: zhusaidong

我的意思是IllegalSQLInterceptor内部过滤下boolean,enum这类不需要判断索引的字段

Comment From: huayanYu

@zhusaidong 你的建议非常好,非常希望你能加入参与进来维护,我们正在吸纳社区维护者。 这个插件比较简单,可以先从这里入手。