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

3.5.0

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

当使用com.baomidou.mybatisplus.core.mapper.BaseMapper#selectBatchIds(...)时,如果我传入长度为0的集合则会报错。这导致我不得不在每次调用此方法及其相关方法时都要校验一次集合是否为空。

我有看到此方法的注释,“idList 主键ID列表(不能为 null 以及 empty)”,但是我不明白为什么这么设计。长度为0的集合并非无意义的值,当发生这样的调用时,完全可以返回一个长度为0的集合作为结果。但是实际上确是抛出异常。

不知道在后续的版本中,是否考虑将集合判empty的逻辑集成进此方法中,而不是抛出SQL异常。

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

报错信息

Comment From: miemieYaho

不支持

Comment From: miemieYaho

你想那么玩就自己写个类实现InnerInterceptor接口的willDoQuery方法,里面去判断要不要继续查询

Comment From: wangguangyuana

public class MyInterceptor implements InnerInterceptor { @Override public boolean willDoQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) throws SQLException { Map map = (Map)parameter; if (map.containsKey("ew")) { LambdaQueryWrapper ewQueryWrapper = (LambdaQueryWrapper)map.get("ew"); MergeSegments expression = ewQueryWrapper.getExpression(); if (expression != null) { NormalSegmentList normal = expression.getNormal(); if (CollectionUtils.isNotEmpty(normal)) { for (int i = 0; i < normal.size(); i++) { ISqlSegment iSqlSegment1 = normal.get(i); if (iSqlSegment1 instanceof SqlKeyword) { SqlKeyword sqlKeyword = (SqlKeyword) iSqlSegment1; String sqlSegment = sqlKeyword.getSqlSegment(); if ("IN".equals(sqlSegment)) { ISqlSegment iSqlSegment2 = normal.get(i + 1); if (iSqlSegment2 instanceof AbstractWrapper) { AbstractWrapper abstractWrapper = (AbstractWrapper) iSqlSegment2; Map paramNameValuePairs = abstractWrapper.getParamNameValuePairs(); // 请问:我该怎么判断这次是否有in条件,以及拿到in的参数列表呢? 找了好久,感觉还是准确定位in条件值为空的情况 } } } } } }

    }
    return true;
}

}

Comment From: wangguangyuana

你想那么玩就自己写个类实现InnerInterceptor接口的willDoQuery方法,里面去判断要不要继续查询

你想那么玩就自己写个类实现InnerInterceptor接口的willDoQuery方法,里面去判断要不要继续查询

你想那么玩就自己写个类实现InnerInterceptor接口的willDoQuery方法,里面去判断要不要继续查询

你想那么玩就自己写个类实现InnerInterceptor接口的willDoQuery方法,里面去判断要不要继续查询

请问:我该怎么判断这次是否有in条件,以及拿到in的参数列表呢? 找了好久,感觉还是准确定位in条件值为空的情况