refactor(relations): 关系数据统一为 camelCase 单一形状 - #13
Merged
Conversation
候选 4:同一概念(表间列关联)此前有两种形状——存储返回的 snake_case RelationRow 穿过 graph/facade 漏到 8+ 消费点,转换逻辑 手写三处,调用方必须同时懂两种命名。改为 store 边界一次映射。 - types.ts 新增 StoredRelation(camelCase 全字段含 id/时间戳), ColumnRelation 派生为 Omit 掉持久化字段的子集——字段名完全一致 - relation/store.ts 删除 RelationRow,rowToRelation 在 SQLite 边界 一次映射;graph/facade/commands/db-tools 只认一种形状 - RelationGraph.getDirectRelations 收为 private(仅内部 BFS 使用), 测试改走公共接口 - 行格式化四变体保持现状(受众差异是需求,不是重复)
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.
候选 4:关系数据两种形状收敛为一种
变更内容
types.ts新增StoredRelation(camelCase 全字段含 id/createdTime/updatedTime);ColumnRelation派生为Omit<StoredRelation, "id" | "createdTime" | "updatedTime">——输入是输出的子集,字段名完全一致relation/store.ts删除RelationRow;rowToRelation在 SQLite 边界一次映射 camelCase;upsert/findByColumns/list返回StoredRelation;SQL 列名不动relation-graph.ts/state/workspace.ts/commands/relations.ts/tools/db-tools.ts只认一种形状(40+ 处属性访问改名)RelationGraph.getDirectRelations收为 private(仅内部 BFS 使用),测试改走公共接口为什么
同一概念此前有两种形状:snake_case
RelationRow从存储一路漏到 8+ 消费点,camelCase 只在图/命令输入侧,转换逻辑手写三处。收敛后一个概念一种形状,加字段/改名不再牵动 4+ 文件。验证
npm run check(tsc)通过npm test230 通过(getDirectRelations 断言改公共接口,跨 schema 反向用 listAll 验证)npm run lint0 errors(13 warnings 存量)npm run fmt+fmt:check通过