🐛 fix(codegen): 统一分析结果与模板导入映射 - #168
Merged
ZhaoXingPeng merged 2 commits intoSep 9, 2026
Merged
Conversation
Owner
Author
实现完成(2026-09-09)当前结论Issue #167 已完成。 变更与设计取舍
验证与证据
兼容性与下一步
|
Owner
Author
验证完成(2026-09-09)当前结论完整单元套件和定向方言回归均通过。新测试证明 imports 计算不再遗漏模板上下文已经支持的 PostgreSQL 时区类型;没有真实数据库或性能结论被写入本 PR。 变更与设计取舍
验证与证据
兼容性与下一步
|
This was referenced Sep 8, 2026
* 🐛 fix(mcp): 补齐 PostgreSQL 时间类型别名映射 * 🐛 fix(codegen): 补齐自增主键模板上下文标记 (#172) * 🐛 fix(codegen): 补齐自增主键模板上下文标记 * 🐛 fix(generator): 修正遗留实体上下文自增标志 (#174) * 🐛 fix(generator): 修正遗留实体上下文自增标志 * 🐛 fix(generator): 保留 Java 属性名内部大小写 (#176) * 🐛 fix(generator): 保留 Java 属性名内部大小写 * 🐛 fix(template): 仅为自增主键启用 generated keys (#178) * 🐛 fix(template): 仅为自增主键启用 generated keys * 🐛 fix(codegen): 统一主键列表与列上下文 (#180) * 🐛 fix(codegen): 统一主键列表与列上下文 * 🐛 fix(mcp): 统一描述与代码生成类型映射 (#182) * 🐛 fix(mcp): 统一描述与代码生成类型映射 * 🐛 fix(codegen): 统一旧入口方言表名发现 (#184) * 🐛 fix(codegen): 统一旧入口方言表名发现 * ♻️ refactor(codegen): 复用统一表名元数据合同 (#186) * ♻️ refactor(codegen): 复用统一表名元数据合同 * 🐛 fix(codegen): 补齐批量分析表名上下文 (#188) * 🐛 fix(codegen): 补齐批量分析表名上下文 * 🐛 fix(database): 持久化 SQLite execute_query 写入 (#190) * 🐛 fix(database): 持久化 SQLite execute_query 写入 * 🐛 fix(governance): 对齐工具注册表数据库能力 (#192) * 🐛 fix(governance): 对齐工具注册表数据库能力 * 🔒 security(mcp-apps): 收紧代码 diff 路径边界 (#194) * 🔒 security(mcp-apps): 收紧代码 diff 路径边界 * 🐛 fix(codegen): 对齐生成文件写入统计与结果状态 (#196) * 🐛 fix(codegen): 对齐生成文件写入统计与结果状态 * ✨ feat(codegen): 统一 DTO 与 VO 生成选项合同 (#198) * ✨ feat(codegen): 统一 DTO 与 VO 生成选项合同 * 📚 docs(governance): 固化 GitHub 元数据正文门禁 (#200) * 📚 docs(governance): 固化 GitHub 元数据正文门禁 * 🐛 fix(database): 回滚失败 SQLite 查询事务 (#202) * 🐛 fix(database): 回滚失败 SQLite 查询事务 * 🐛 fix(schema): 规范图算法重复表输入 (#204) * 🐛 fix(schema): 规范图算法重复表输入 * 🐛 fix(dependencies): 隔离版本分析状态 (#206) * 🐛 fix(dependencies): 隔离版本分析状态 * 🐛 fix(cli): 统一解析 MCP 响应 (#208) * 🐛 fix(cli): 统一解析 MCP 响应 * ✨ feat(connection): 增加 MCP 连接释放工具 (#210) * ✨ feat(connection): 增加 MCP 连接释放工具 * ⚡ perf(mcp): 隔离同步数据库调用与事件循环 (#212)
ZhaoXingPeng
added a commit
that referenced
this pull request
Sep 9, 2026
* 🐛 fix(codegen): 规范无前缀模板输出路径 * 🐛 fix(codegen): 统一分析结果与模板导入映射 (#168) * 🐛 fix(codegen): 统一分析结果与模板导入映射 * 🐛 fix(mcp): 补齐 PostgreSQL 时间类型别名映射 (#170) * 🐛 fix(mcp): 补齐 PostgreSQL 时间类型别名映射 * 🐛 fix(codegen): 补齐自增主键模板上下文标记 (#172) * 🐛 fix(codegen): 补齐自增主键模板上下文标记 * 🐛 fix(generator): 修正遗留实体上下文自增标志 (#174) * 🐛 fix(generator): 修正遗留实体上下文自增标志 * 🐛 fix(generator): 保留 Java 属性名内部大小写 (#176) * 🐛 fix(generator): 保留 Java 属性名内部大小写 * 🐛 fix(template): 仅为自增主键启用 generated keys (#178) * 🐛 fix(template): 仅为自增主键启用 generated keys * 🐛 fix(codegen): 统一主键列表与列上下文 (#180) * 🐛 fix(codegen): 统一主键列表与列上下文 * 🐛 fix(mcp): 统一描述与代码生成类型映射 (#182) * 🐛 fix(mcp): 统一描述与代码生成类型映射 * 🐛 fix(codegen): 统一旧入口方言表名发现 (#184) * 🐛 fix(codegen): 统一旧入口方言表名发现 * ♻️ refactor(codegen): 复用统一表名元数据合同 (#186) * ♻️ refactor(codegen): 复用统一表名元数据合同 * 🐛 fix(codegen): 补齐批量分析表名上下文 (#188) * 🐛 fix(codegen): 补齐批量分析表名上下文 * 🐛 fix(database): 持久化 SQLite execute_query 写入 (#190) * 🐛 fix(database): 持久化 SQLite execute_query 写入 * 🐛 fix(governance): 对齐工具注册表数据库能力 (#192) * 🐛 fix(governance): 对齐工具注册表数据库能力 * 🔒 security(mcp-apps): 收紧代码 diff 路径边界 (#194) * 🔒 security(mcp-apps): 收紧代码 diff 路径边界 * 🐛 fix(codegen): 对齐生成文件写入统计与结果状态 (#196) * 🐛 fix(codegen): 对齐生成文件写入统计与结果状态 * ✨ feat(codegen): 统一 DTO 与 VO 生成选项合同 (#198) * ✨ feat(codegen): 统一 DTO 与 VO 生成选项合同 * 📚 docs(governance): 固化 GitHub 元数据正文门禁 (#200) * 📚 docs(governance): 固化 GitHub 元数据正文门禁 * 🐛 fix(database): 回滚失败 SQLite 查询事务 (#202) * 🐛 fix(database): 回滚失败 SQLite 查询事务 * 🐛 fix(schema): 规范图算法重复表输入 (#204) * 🐛 fix(schema): 规范图算法重复表输入 * 🐛 fix(dependencies): 隔离版本分析状态 (#206) * 🐛 fix(dependencies): 隔离版本分析状态 * 🐛 fix(cli): 统一解析 MCP 响应 (#208) * 🐛 fix(cli): 统一解析 MCP 响应 * ✨ feat(connection): 增加 MCP 连接释放工具 (#210) * ✨ feat(connection): 增加 MCP 连接释放工具 * ⚡ perf(mcp): 隔离同步数据库调用与事件循环 (#212)
ZhaoXingPeng
added a commit
that referenced
this pull request
Sep 9, 2026
* 🐛 fix(codegen): 规范无前缀模板输出路径 * 🐛 fix(codegen): 统一分析结果与模板导入映射 (#168) * 🐛 fix(codegen): 统一分析结果与模板导入映射 * 🐛 fix(mcp): 补齐 PostgreSQL 时间类型别名映射 (#170) * 🐛 fix(mcp): 补齐 PostgreSQL 时间类型别名映射 * 🐛 fix(codegen): 补齐自增主键模板上下文标记 (#172) * 🐛 fix(codegen): 补齐自增主键模板上下文标记 * 🐛 fix(generator): 修正遗留实体上下文自增标志 (#174) * 🐛 fix(generator): 修正遗留实体上下文自增标志 * 🐛 fix(generator): 保留 Java 属性名内部大小写 (#176) * 🐛 fix(generator): 保留 Java 属性名内部大小写 * 🐛 fix(template): 仅为自增主键启用 generated keys (#178) * 🐛 fix(template): 仅为自增主键启用 generated keys * 🐛 fix(codegen): 统一主键列表与列上下文 (#180) * 🐛 fix(codegen): 统一主键列表与列上下文 * 🐛 fix(mcp): 统一描述与代码生成类型映射 (#182) * 🐛 fix(mcp): 统一描述与代码生成类型映射 * 🐛 fix(codegen): 统一旧入口方言表名发现 (#184) * 🐛 fix(codegen): 统一旧入口方言表名发现 * ♻️ refactor(codegen): 复用统一表名元数据合同 (#186) * ♻️ refactor(codegen): 复用统一表名元数据合同 * 🐛 fix(codegen): 补齐批量分析表名上下文 (#188) * 🐛 fix(codegen): 补齐批量分析表名上下文 * 🐛 fix(database): 持久化 SQLite execute_query 写入 (#190) * 🐛 fix(database): 持久化 SQLite execute_query 写入 * 🐛 fix(governance): 对齐工具注册表数据库能力 (#192) * 🐛 fix(governance): 对齐工具注册表数据库能力 * 🔒 security(mcp-apps): 收紧代码 diff 路径边界 (#194) * 🔒 security(mcp-apps): 收紧代码 diff 路径边界 * 🐛 fix(codegen): 对齐生成文件写入统计与结果状态 (#196) * 🐛 fix(codegen): 对齐生成文件写入统计与结果状态 * ✨ feat(codegen): 统一 DTO 与 VO 生成选项合同 (#198) * ✨ feat(codegen): 统一 DTO 与 VO 生成选项合同 * 📚 docs(governance): 固化 GitHub 元数据正文门禁 (#200) * 📚 docs(governance): 固化 GitHub 元数据正文门禁 * 🐛 fix(database): 回滚失败 SQLite 查询事务 (#202) * 🐛 fix(database): 回滚失败 SQLite 查询事务 * 🐛 fix(schema): 规范图算法重复表输入 (#204) * 🐛 fix(schema): 规范图算法重复表输入 * 🐛 fix(dependencies): 隔离版本分析状态 (#206) * 🐛 fix(dependencies): 隔离版本分析状态 * 🐛 fix(cli): 统一解析 MCP 响应 (#208) * 🐛 fix(cli): 统一解析 MCP 响应 * ✨ feat(connection): 增加 MCP 连接释放工具 (#210) * ✨ feat(connection): 增加 MCP 连接释放工具 * ⚡ perf(mcp): 隔离同步数据库调用与事件循环 (#212)
ZhaoXingPeng
added a commit
that referenced
this pull request
Sep 9, 2026
* 🐛 fix(mcp): 收口全部 MCP 响应 JSON 序列化 * 🐛 fix(codegen): 规范无前缀模板输出路径 (#166) * 🐛 fix(codegen): 规范无前缀模板输出路径 * 🐛 fix(codegen): 统一分析结果与模板导入映射 (#168) * 🐛 fix(codegen): 统一分析结果与模板导入映射 * 🐛 fix(mcp): 补齐 PostgreSQL 时间类型别名映射 (#170) * 🐛 fix(mcp): 补齐 PostgreSQL 时间类型别名映射 * 🐛 fix(codegen): 补齐自增主键模板上下文标记 (#172) * 🐛 fix(codegen): 补齐自增主键模板上下文标记 * 🐛 fix(generator): 修正遗留实体上下文自增标志 (#174) * 🐛 fix(generator): 修正遗留实体上下文自增标志 * 🐛 fix(generator): 保留 Java 属性名内部大小写 (#176) * 🐛 fix(generator): 保留 Java 属性名内部大小写 * 🐛 fix(template): 仅为自增主键启用 generated keys (#178) * 🐛 fix(template): 仅为自增主键启用 generated keys * 🐛 fix(codegen): 统一主键列表与列上下文 (#180) * 🐛 fix(codegen): 统一主键列表与列上下文 * 🐛 fix(mcp): 统一描述与代码生成类型映射 (#182) * 🐛 fix(mcp): 统一描述与代码生成类型映射 * 🐛 fix(codegen): 统一旧入口方言表名发现 (#184) * 🐛 fix(codegen): 统一旧入口方言表名发现 * ♻️ refactor(codegen): 复用统一表名元数据合同 (#186) * ♻️ refactor(codegen): 复用统一表名元数据合同 * 🐛 fix(codegen): 补齐批量分析表名上下文 (#188) * 🐛 fix(codegen): 补齐批量分析表名上下文 * 🐛 fix(database): 持久化 SQLite execute_query 写入 (#190) * 🐛 fix(database): 持久化 SQLite execute_query 写入 * 🐛 fix(governance): 对齐工具注册表数据库能力 (#192) * 🐛 fix(governance): 对齐工具注册表数据库能力 * 🔒 security(mcp-apps): 收紧代码 diff 路径边界 (#194) * 🔒 security(mcp-apps): 收紧代码 diff 路径边界 * 🐛 fix(codegen): 对齐生成文件写入统计与结果状态 (#196) * 🐛 fix(codegen): 对齐生成文件写入统计与结果状态 * ✨ feat(codegen): 统一 DTO 与 VO 生成选项合同 (#198) * ✨ feat(codegen): 统一 DTO 与 VO 生成选项合同 * 📚 docs(governance): 固化 GitHub 元数据正文门禁 (#200) * 📚 docs(governance): 固化 GitHub 元数据正文门禁 * 🐛 fix(database): 回滚失败 SQLite 查询事务 (#202) * 🐛 fix(database): 回滚失败 SQLite 查询事务 * 🐛 fix(schema): 规范图算法重复表输入 (#204) * 🐛 fix(schema): 规范图算法重复表输入 * 🐛 fix(dependencies): 隔离版本分析状态 (#206) * 🐛 fix(dependencies): 隔离版本分析状态 * 🐛 fix(cli): 统一解析 MCP 响应 (#208) * 🐛 fix(cli): 统一解析 MCP 响应 * ✨ feat(connection): 增加 MCP 连接释放工具 (#210) * ✨ feat(connection): 增加 MCP 连接释放工具 * ⚡ perf(mcp): 隔离同步数据库调用与事件循环 (#212)
5 tasks
ZhaoXingPeng
added a commit
that referenced
this pull request
Sep 9, 2026
* 🐛 fix(mcp): 收口全部 MCP 响应 JSON 序列化 * 🐛 fix(codegen): 规范无前缀模板输出路径 (#166) * 🐛 fix(codegen): 规范无前缀模板输出路径 * 🐛 fix(codegen): 统一分析结果与模板导入映射 (#168) * 🐛 fix(codegen): 统一分析结果与模板导入映射 * 🐛 fix(mcp): 补齐 PostgreSQL 时间类型别名映射 (#170) * 🐛 fix(mcp): 补齐 PostgreSQL 时间类型别名映射 * 🐛 fix(codegen): 补齐自增主键模板上下文标记 (#172) * 🐛 fix(codegen): 补齐自增主键模板上下文标记 * 🐛 fix(generator): 修正遗留实体上下文自增标志 (#174) * 🐛 fix(generator): 修正遗留实体上下文自增标志 * 🐛 fix(generator): 保留 Java 属性名内部大小写 (#176) * 🐛 fix(generator): 保留 Java 属性名内部大小写 * 🐛 fix(template): 仅为自增主键启用 generated keys (#178) * 🐛 fix(template): 仅为自增主键启用 generated keys * 🐛 fix(codegen): 统一主键列表与列上下文 (#180) * 🐛 fix(codegen): 统一主键列表与列上下文 * 🐛 fix(mcp): 统一描述与代码生成类型映射 (#182) * 🐛 fix(mcp): 统一描述与代码生成类型映射 * 🐛 fix(codegen): 统一旧入口方言表名发现 (#184) * 🐛 fix(codegen): 统一旧入口方言表名发现 * ♻️ refactor(codegen): 复用统一表名元数据合同 (#186) * ♻️ refactor(codegen): 复用统一表名元数据合同 * 🐛 fix(codegen): 补齐批量分析表名上下文 (#188) * 🐛 fix(codegen): 补齐批量分析表名上下文 * 🐛 fix(database): 持久化 SQLite execute_query 写入 (#190) * 🐛 fix(database): 持久化 SQLite execute_query 写入 * 🐛 fix(governance): 对齐工具注册表数据库能力 (#192) * 🐛 fix(governance): 对齐工具注册表数据库能力 * 🔒 security(mcp-apps): 收紧代码 diff 路径边界 (#194) * 🔒 security(mcp-apps): 收紧代码 diff 路径边界 * 🐛 fix(codegen): 对齐生成文件写入统计与结果状态 (#196) * 🐛 fix(codegen): 对齐生成文件写入统计与结果状态 * ✨ feat(codegen): 统一 DTO 与 VO 生成选项合同 (#198) * ✨ feat(codegen): 统一 DTO 与 VO 生成选项合同 * 📚 docs(governance): 固化 GitHub 元数据正文门禁 (#200) * 📚 docs(governance): 固化 GitHub 元数据正文门禁 * 🐛 fix(database): 回滚失败 SQLite 查询事务 (#202) * 🐛 fix(database): 回滚失败 SQLite 查询事务 * 🐛 fix(schema): 规范图算法重复表输入 (#204) * 🐛 fix(schema): 规范图算法重复表输入 * 🐛 fix(dependencies): 隔离版本分析状态 (#206) * 🐛 fix(dependencies): 隔离版本分析状态 * 🐛 fix(cli): 统一解析 MCP 响应 (#208) * 🐛 fix(cli): 统一解析 MCP 响应 * ✨ feat(connection): 增加 MCP 连接释放工具 (#210) * ✨ feat(connection): 增加 MCP 连接释放工具 * ⚡ perf(mcp): 隔离同步数据库调用与事件循环 (#212)
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.
关联 Issue
Closes #167
背景(Situation)
CodegenAnalyzer._calculate_imports_needed()目前自行遍历 Java 类型,只添加BigDecimal、LocalDate、LocalTime和LocalDateTime四种导入。TemplateContextBuilder._build_imports()已通过DialectAdapter支持更多类型,例如 PostgreSQLTIMESTAMPTZ -> OffsetDateTime。同一张表因此会出现分析响应imports_needed不完整、但实际模板上下文已有 import 的不一致,调用方若依据分析结果组装代码会漏导入。任务(Task)
让代码生成分析结果复用模板上下文的方言映射和导入表,保持返回字段、排序、数据库类型参数和未知类型语义不变。
行动(Action)
2ef0ac0_calculate_imports_needed()改为调用TemplateContextBuilder._build_imports(..., template_category="Default"),消除重复的四类型分支。TIMESTAMPTZ+ Decimal 回归,断言OffsetDateTime与BigDecimal导入完整、去重且排序稳定。验证(Verification)
环境:Windows,仓库
.venv,Python 3.12.12,pytest 9.1.1,Ruff 来自.venv。实验与证据(Evidence)
固定输入包含 PostgreSQL
TIMESTAMPTZ和DECIMAL(12,2)两列。修复前手写分支无法返回java.time.OffsetDateTime;当前分析器与模板上下文均返回java.math.BigDecimal、java.time.OffsetDateTime,且输出按字典序排列。未运行真实 MySQL/PostgreSQL 或性能实验,因此不宣称生产方言覆盖或性能提升。兼容性、风险与回滚
2ef0ac0即可,不涉及数据库、配置迁移或生成物。fix/165-codegen-path-normalization,仅包含本主题一个新增提交;待前置代码生成 PR 按顺序合并后再切回main。后续(Next)
合并前仅对最终 HEAD 检查一次 required checks;后续可继续盘点 legacy
TemplateContext与新TemplateContextBuilder的重复导入逻辑,另开 Issue 处理。