Skip to content

支持在 join on 子句中追加 scoped DSL 条件 - #1

Merged
bobdeng merged 1 commit into
bobdeng:mainfrom
weiqinghang:codex/join-on-scoped-dsl
Mar 30, 2026
Merged

bobdeng merged 1 commit into
bobdeng:mainfrom
weiqinghang:codex/join-on-scoped-dsl

Conversation

@weiqinghang

Copy link
Copy Markdown
Contributor

变更说明

本 PR 为 dslquery 增加了在关联查询 join on 子句中追加额外条件的能力,同时保持现有注解模型和字符串 DSL 风格不变。

新增能力

  • 新增 @JoinOn 注解,可在关联字段上声明额外的 on 条件
  • 新增 DSLQuery.joinOn(path, dsl) 运行时 API,可按关联路径动态追加 on 条件
  • 支持 scoped DSL 解析:
    • 裸字段名或 self.xxx:当前 join 目标对象
    • parent.xxx:当前 join 的上一级对象
    • root.xxx:根查询对象
  • 支持 @fieldPath 形式的字段引用值,例如:
    • @parent.tenantId
    • @root.areaCode

实现细节

  • JoinField 渲染 join SQL 时,将基础关联条件和额外 on 条件统一合并
  • 新增 JoinOnSQLBuilder,专门负责 scoped DSL 到 SQL 的转换和参数绑定
  • SingleExpression 增加了仅对 join-on builder 生效的字段引用值解析
  • 保持原有 where 语义不变,普通 where 中以 @ 开头的值仍按字面量处理

文档与测试

  • 补充 README,说明 @JoinOnjoinOn(path, dsl)self/parent/root 的用法
  • 新增 API 和查询行为测试
  • 增加兼容性回归测试,确保未使用 join-on 扩展时行为不变

验证

已执行:

gradle -I /tmp/gradle8-jacoco-compat.init.gradle test

结果:

  • BUILD SUCCESSFUL

@bobdeng
bobdeng merged commit 111b60a into bobdeng:main Mar 30, 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