fix(PostgreSQL): 使用 jsonb 可索引操作符查询键#114
Merged
Merged
Conversation
ebf7dac to
381739c
Compare
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 4.2 #114 +/- ##
=============================================
+ Coverage 64.92% 79.14% +14.21%
- Complexity 2341 3391 +1050
=============================================
Files 343 374 +31
Lines 9375 10905 +1530
Branches 940 1309 +369
=============================================
+ Hits 6087 8631 +2544
+ Misses 2810 1637 -1173
- Partials 478 637 +159 ☔ 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_exists*函数改为?/?|/?&操作符。jsonb_exists_any等函数形式无法命中jsonb_opsGIN 索引的问题。?操作符与预编译占位符冲突。核心变动
PostgresqlJsonbExistTermFragmentBuilderexist:生成column ? ?。all:生成column ?& array[...]。any/keys/ 通用in、overlap:生成column ?| array[...]。JdbcSqlExecutor/PostgresqlDriverUtilsprepareStatement前判断连接是否为 PostgreSQL。?/?|/?&操作符转义为 JDBC 可识别的??/??|/??&。SqlRequest保持原生 PostgreSQL SQL 形态,不污染 R2DBC。SqlUtils?操作符转义方法,处理字符串、双引号标识符、行注释和块注释。?/?|/?&。设计与测试目标
?|,并倾向 JDBC 单独处理而不是让 R2DBC 兼容??。?、?|、?&操作符生成、JDBC 执行前转义、R2DBC$n占位符替换和 native SQL 日志还原。jsonb_opsGIN 索引用于 key exists 查询。未做压力测试,本 PR 以 SQL 形态和真实 PostgreSQL 集成执行作为替代验证。测试结果
mvn -pl hsweb-easy-orm-rdb -Dtest=PostgresqlJsonbExistBuilderCoverageTest,SqlUtilsCoverageTest,SqlUtilsTest,SqlUtilsBranchTest testmvn -pl hsweb-easy-orm-rdb -Dtest=PostgresqlBasicTest#testJsonbExistTerm testpostgres:11-alpine。data ? ?、data ?| array[ ?,? ]、data ?& array[ ?,? ];执行前由 JDBC 链路转义。mvn -pl hsweb-easy-orm-rdb -Dtest=PostgresqlReactiveTests#testJsonbExistTerm testpostgres:11-alpine。data ? $1、data ?| array[ $1,$2 ]、data ?& array[ $1,$2 ]。data ?| array[?,?]会报“未设定参数值 3”,确认 JDBC 需要转义。data ?| array[$1,$2]和data ? $1通过,确认不需要??。git diff --check通过。文档同步情况
风险与说明
SqlUtils参数替换逻辑。?/?|/?&为 PostgreSQL JSONB 操作符,不影响其他数据库方言的 JSON 实现。?操作符,避免 PostgreSQL JDBC 将其误判为预编译占位符。?/?|/?&操作符,不再依赖??兼容路径。