Skip to content

feat(rdb): 支持 countRows 选项优化非空列计数 - #125

Merged
zhou-hao merged 4 commits into
hs-web:4.2from
goten7:codex/postgresql-count-nonnull
Oct 4, 2026
Merged

zhou-hao merged 4 commits into
hs-web:4.2from
goten7:codex/postgresql-count-nonnull

Conversation

@goten7

@goten7 goten7 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

变更说明

为内置 count 增加可选的 countRows 参数。目标列元数据确认为非空且 countRows=true 时生成 count(*),优先于 distinct、arg 等选项;未启用或目标列可空时,沿用原有 SQL 生成逻辑。

  • RDBFeatures.count 使用继承 SimpleFunctionFragmentBuilder 的实现,保留字段声明类型。
  • 表级、Schema 级自定义 count 仍通过原有 Feature 机制覆盖内置实现。
  • 调用方只需设置 column.option("countRows", true);旧版内置函数会忽略该选项,继续按原有选项生成 SQL。
  • 调用方需确保关联查询不会使目标非空列在结果集中变为 NULL。

验证

  • 新增 9 个单元测试,覆盖非空/可空列、选项启停、未解析列、countRows 优先级、原有 distinct/arg 行为、自定义函数、旧版函数行为及 H2 方言。
  • git diff --check:通过。
  • 本地 Java 编译与单元测试未执行。待执行命令:zsh -lic 'java21; mvn -pl hsweb-easy-orm-rdb -am -Dtest=CountFunctionFragmentBuilderTest -Dsurefire.failIfNoSpecifiedTests=false test'。
  • 实际性能需结合目标数据库索引和执行计划验证。

@zhou-hao

Copy link
Copy Markdown
Member

自定义针对count的 FunctionFragmentBuilder 覆盖 RDBFeatures.count 就行了吧? 或者直接优化 RDBFeatures.count

@goten7 goten7 changed the title perf(rdb): 优化 PostgreSQL 非空列计数并保留自定义 count feat(rdb): 支持 countRows 选项优化非空列计数 Sep 30, 2026
@zhou-hao
zhou-hao merged commit 3f3f785 into hs-web:4.2 Oct 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants