优化count查询兼容informix

This commit is contained in:
Looly 2023-05-09 10:07:09 +08:00
parent d87d0c8131
commit a9689a925e
2 changed files with 5 additions and 2 deletions

View File

@ -2,11 +2,12 @@
# 🚀Changelog
-------------------------------------------------------------------------------------------------------------
# 5.8.19.M1 (2023-05-05)
# 5.8.19.M1 (2023-05-09)
### 🐣新特性
* 【db 】 优化HttpRequest.toString()内容打印issue#3072@Github
* 【poi 】 优化Sax方式读取时空白行返回0修改为返回-1issue#I6WYF6@Gitee
* 【db 】 优化count查询兼容informixissue#I713XQ@Gitee
### 🐞Bug修复
* 【core 】 修复URLUtil.decode无法解码UTF-16问题issue#3063@Github

View File

@ -148,8 +148,10 @@ public interface Dialect extends Serializable {
* @since 5.7.2
*/
default PreparedStatement psForCount(Connection conn, SqlBuilder sqlBuilder) throws SQLException {
// https://gitee.com/dromara/hutool/issues/I713XQ
// 为了兼容informix等数据库此处使用count(*)而非count(1)
sqlBuilder = sqlBuilder
.insertPreFragment("SELECT count(1) from(")
.insertPreFragment("SELECT count(*) from(")
// issue#I3IJ8X@Gitee在子查询时需设置单独别名此处为了防止和用户的表名冲突使用自定义的较长别名
.append(") hutool_alias_count_");
return psForPage(conn, sqlBuilder, null);