Describe the bug
PaginationHelper#fetchPage设计问题,导致不能使用 ?
方法PaginationHelper#fetchPage的执行过程是先查询 count (假定为 sql-1), 再查询 指定页面的数据 (假定为sql-2)。
但方法中强制要求 sql-1, sql-2 的参数必须完全一样,就导致在执行sql-2时,无法将 offset, pagesize 以 占位符 ? 形式传入。
Expected behavior
在相关的分页sql中可以使用 占位符 ?
Actually behavior
实际上不能使用。一旦使用,在 执行select count时就会出错。
How to Reproduce
Steps to reproduce the behavior:
- 将任意一个数据库的插件(例如mysql)的
HistoryConfigInfoMapper # pageFindConfigHistoryFetchRows 方法中,context.getStartRow(), context.getPageSize() 参数,调整为以 ? 方式生成SQL,去执行就会报错。
例如:
public class HistoryConfigInfoMapperByMySql extends AbstractMapperByMysql implements HistoryConfigInfoMapper {
// 其它方法这里忽略
@Override
public MapperResult pageFindConfigHistoryFetchRows(MapperContext context) {
String sql =
"SELECT nid,data_id,group_id,tenant_id,app_name,src_ip,src_user,op_type,gmt_create,gmt_modified FROM his_config_info "
+ "WHERE data_id = ? AND group_id = ? AND tenant_id = ? ORDER BY nid DESC LIMIT ?, ?";
// + context.getStartRow() + "," +context.getPageSize( );
return new MapperResult(sql, CollectionUtils.list(context.getWhereParameter(FieldConstant.DATA_ID),
context.getWhereParameter(FieldConstant.GROUP_ID), context.getWhereParameter(FieldConstant.TENANT_ID), context.getStartRow(), context.getPageSize()));
}
}
Describe the bug
PaginationHelper#fetchPage设计问题,导致不能使用?方法
PaginationHelper#fetchPage的执行过程是先查询 count (假定为 sql-1), 再查询 指定页面的数据 (假定为sql-2)。但方法中强制要求 sql-1, sql-2 的参数必须完全一样,就导致在执行sql-2时,无法将 offset, pagesize 以 占位符
?形式传入。Expected behavior
在相关的分页sql中可以使用 占位符
?Actually behavior
实际上不能使用。一旦使用,在 执行select count时就会出错。
How to Reproduce
Steps to reproduce the behavior:
HistoryConfigInfoMapper # pageFindConfigHistoryFetchRows方法中,context.getStartRow(), context.getPageSize() 参数,调整为以?方式生成SQL,去执行就会报错。例如: