feat(PostgreSQL): 支持 jsonb 通用查询条件#113
Merged
Merged
Conversation
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 4.2 #113 +/- ##
=============================================
+ Coverage 64.92% 79.24% +14.31%
- Complexity 2341 3357 +1016
=============================================
Files 343 374 +31
Lines 9375 10834 +1459
Branches 940 1284 +344
=============================================
+ Hits 6087 8585 +2498
+ Misses 2810 1622 -1188
- Partials 478 627 +149 ☔ 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.
目的
jsonb字段补齐与数组字段一致的通用TermType查询能力。options在默认行为和 key/jsonb 语义之间切换,减少data$exist$contains这类混合语义写法。?/?|/?&操作符,便于匹配 PostgreSQLjsonb_opsGIN 索引。核心变动
PostgresqlJsonbTermFragmentBuilder:in/nin、contains/ncontains、contained/ncontained、overlap/noverlap。contains/contained映射为@>/<@。in/overlap映射为?|。key、keys、any、all、json、contains、containedoptions 覆盖默认行为。PostgresqlJsonbExistTermFragmentBuilder:??/??|/??&,实际 SQL 为 PostgreSQL?/?|/?&。exist、exist$any、exist$all、exist$contains、exist$contained行为入口。SqlUtils:$n占位符转换时识别 JDBC 风格??/??|/??&转义操作符。x ?? y文本不误判的回归行为。PostgresqlSchemaMetadata中为JsonbType注册通用TermTypebuilder。设计与测试目标
TermType+ options 指定行为”的方案;后续根据索引命中要求调整为?/?|/?&操作符实现。$options解析、JDBC 与 R2DBC 集成路径。?/?|/?&操作符以匹配jsonb_opsGIN 索引能力。未新增复杂分页、聚合或批量写入。SqlUtils转义逻辑处补充了简要兼容说明。测试结果
mvn -pl hsweb-easy-orm-rdb -Dtest=PostgresqlJsonbExistBuilderCoverageTest,SqlUtilsCoverageTest,SqlUtilsTest,SqlUtilsBranchTest test??|/??&转义还原和原有 JSONB 操作符参数替换回归。mvn -pl hsweb-easy-orm-rdb -Dtest=PostgresqlBasicTest#testJsonbExistTerm testpostgres:11-alpine??/??|/??&,native SQL 渲染为?/?|/?&。mvn -pl hsweb-easy-orm-rdb -Dtest=PostgresqlReactiveTests#testJsonbExistTerm testpostgres:11-alpine?/?|/?&并正确转换其他参数为$n。git diff --checkPostgresqlJsonbTermFragmentBuilderline:40/42,95.24%;branch:16/21,76.19%PostgresqlJsonbExistTermFragmentBuilderline:65/72,90.28%;branch:37/44,84.09%文档同步情况
风险与说明
JsonbType字段查询条件构建,以及SqlUtils对 PostgreSQL JSONB?操作符的参数替换/日志渲染识别。exist与exist$any/all/contains/contained行为入口;SQL 从函数形式调整为可索引操作符形式。overlap默认按“任意 key 存在”解释,即?|;需要对象 containment 时可使用contains或jsonoption。