Repository navigation
fix(列映射): 修复SQL表达式编码与结果重复解码 - #140
Merged
Merged
Conversation
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 4.2 #140 +/- ##
=============================================
+ Coverage 64.92% 81.13% +16.20%
- Complexity 2341 3725 +1384
=============================================
Files 343 384 +41
Lines 9375 11419 +2044
Branches 940 1405 +465
=============================================
+ Hits 6087 9265 +3178
+ Misses 2810 1514 -1296
- Partials 478 640 +162 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
原生 JSON 更新时,列 codec 返回 NativeSql,但 UPDATE 构建器仍强转编码前的 Map/String,导致 ClassCastException;PostgreSQL R2DBC 将 SQL NULL 按 String 绑定到 JSON/JSONB 列时会报 42804。实体查询又可能同时经过查询层与映射层解码,使位枚举数组变成空数组、非幂等 codec 执行两次。
在现有片段层统一写入值契约:SqlFragments.encodeValue 保留显式 SQL、编码普通值一次,AppendableSqlFragments.addValue 按编码结果追加 SQL 和参数或普通占位符。UPDATE、多行/逐行 INSERT、旧 MySQL/PG upsert 和 Oracle/SQL Server 写入器复用此契约,修复旧 PostgreSQL upsert 的 JSON UPDATE 表达式绑定问题。批量 INSERT 保留参数数组复用,普通 UPDATE 直接追加主片段,避免每列临时容器;默认值、列省略、Oracle CLOB 处理、MERGE 显式 SQL 限制和 COALESCE 策略仍归写入器负责。
逐行 INSERT 同时修复两个既有组合缺陷:按输入列原始位置读取值和函数,避免过滤未知/不可插入列后静默写错值;函数与普通值二选一,分隔符先于该列片段追加,避免函数与原值重复拼接。函数不执行该列的默认值或普通值编码,没有新增配置、类型或公共 API。
仅 PostgreSQL 原生 JSON/JSONB 将 SQL NULL 输出为无参数 null 表达式,其他 JSON 类型保留原空参数绑定。JSON 文档 "null" 仍作为非空值;UPDATE 的 Java null 仍表示省略,NullValue 表示显式清空。
列上下文通过默认 null 的 getDecodedColumn() 记录完成解码的列实例,decode(targetColumn) 统一同一列跳过和不同目标映射的解码。共享 codec 的不同列仍分别接收各自元数据;无 codec 且结果未变化时复用原上下文。copyOf(context) 提供保留解码状态的派生入口,小写列包装器同时回传替换后的行实例。原四参数构造器保留;查询列事件、Map/自定义包装器、直接 executor 与单列查询保留原契约。仅扩展现有接口,不新增类型、配置、缓存或响应式操作符。
验证(JDK 21):
保留的既有限制:默认 MySQL 批量 upsert 使用 COALESCE,不能用显式 NullValue 清空已有值;外部包装器用原四参数构造器复制上下文时仍丢失解码状态,应使用 copyOf(context) 或透传第五参数。没有改变这两项既有语义。
最终证据:output/entity-extension/coverage-review/{accepted-validation.log,accepted.exec,released-fixed.log,candidate-fixed.log} 及 codec-compatibility-probe/*coverage-fix.log;既有组件证据为 easyorm-value-contract-component-final.log。原 red/stage 和所有旧版对照日志保留。README 已同步编码、逐行 INSERT 和上下文契约。PostgreSQL/MySQL 测试 provider 仅在未提供外部连接时启动容器;MySQL JSON 测试遵循既有 mysql8.db 配置。