Skip to content

fix(rdb): 修复 upsert 批量值场景 ignoreUpdate 与列去重异常#107

Merged
zhou-hao merged 1 commit into
4.2from
fix/upsert-ignore-update-batch-values
May 20, 2026
Merged

fix(rdb): 修复 upsert 批量值场景 ignoreUpdate 与列去重异常#107
zhou-hao merged 1 commit into
4.2from
fix/upsert-ignore-update-batch-values

Conversation

@zhou-hao
Copy link
Copy Markdown
Member

目的

  • 修复 upsert 在批量 values(List<Map<String,Object>>) 场景下 ignoreUpdate 提前声明不生效的问题
  • 修复 ignoreUpdate 与批量补列组合时可能出现的列重复问题
  • 修复缺失主键/唯一键值时批量插入去重逻辑的边界异常,避免影响相关 upsert 路径

核心变动

  • DefaultUpsertOperator
    • 缓存 ignoreUpdate 指定列
    • 支持先 ignoreUpdate(...)values(List<Map<String,Object>>)
  • UpsertColumn
    • 排除 updateIgnoreequals/hashCode 的影响,避免 LinkedHashSet 去重异常
  • BatchInsertSqlBuilder
    • 调整批量主键/唯一键去重逻辑,仅在键值完整时参与重复过滤
  • 新增/补充 upsert 相关单元与 H2 集成测试
    • 覆盖批量 map 值、列缺失、部分缺失、ignoreUpdate 生效与列不重复等场景

测试结果

  • 命令:export JAVA_HOME=$(/usr/libexec/java_home -v 17) && export PATH="$JAVA_HOME/bin:$PATH" && mvn -pl hsweb-easy-orm-rdb -Dtest=DefaultUpsertOperatorTest,DefaultSaveOrUpdateOperatorTest,DefaultDatabaseOperatorTest,BuildParameterInsertOperatorTest test
  • 测试结果:14 passed, 0 failed, 0 skipped
  • 覆盖率(本次测试命令生成的 jacoco 报告):line 28.7%, branch 20.7%

文档同步情况

  • 未同步文档
  • 原因:本次为 ORM 内部行为修复与测试补充,未引入新的外部使用方式或配置项

风险与说明

  • 影响范围:hsweb-easy-orm-rdb 中 upsert 批量 map 值路径与批量插入去重逻辑
  • 已覆盖场景:
    • ignoreUpdate 先声明后批量赋值
    • ignore 列在全部/部分 map 中缺失
    • 列去重与批量 upsert/update/insert 回归
  • 未覆盖场景:其他数据库方言下的端到端执行仍主要依赖现有测试集

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 30.76923% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.69%. Comparing base (68b2764) to head (e5ab8f7).
⚠️ Report is 40 commits behind head on 4.2.

Files with missing lines Patch % Lines
...uilder/fragments/insert/BatchInsertSqlBuilder.java 0.00% 7 Missing ⚠️
...rdb/operator/dml/upsert/DefaultUpsertOperator.java 66.66% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                4.2     #107      +/-   ##
============================================
+ Coverage     64.92%   65.69%   +0.76%     
- Complexity     2341     2394      +53     
============================================
  Files           343      357      +14     
  Lines          9375     9987     +612     
  Branches        940     1125     +185     
============================================
+ Hits           6087     6561     +474     
- Misses         2810     2861      +51     
- Partials        478      565      +87     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zhou-hao zhou-hao merged commit 2596a1d into 4.2 May 20, 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