🐛 fix(metadata): 正确识别 SQLite 自增主键 - #106
Merged
Merged
Conversation
Owner
Author
|
问题复现:对 |
Owner
Author
|
实现记录:新增 SQLite 表 DDL 查询,从 sqlite_master 读取并识别 AUTOINCREMENT;表名通过参数绑定,未引入 SQL 标识符拼接。 |
Owner
Author
|
行为对比:修复后自增 INTEGER 主键返回 auto_increment=true,普通 INTEGER 主键和非主键列仍返回 false。 |
Owner
Author
|
测试记录:新增真实 SQLite fixture;元数据和跨数据库契约测试 14 项通过,完整单元测试 650 项通过,Ruff 和 diff 检查通过。 |
Owner
Author
|
边界说明:SQLite 只在存在主键列时查询表 DDL,减少无关查询;本次未建立可比性能基准,性能数据未测量。 |
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.
背景
SQLite 的 PRAGMA table_info 返回 INTEGER PRIMARY KEY AUTOINCREMENT 列的声明类型为 INTEGER,不会把 AUTOINCREMENT 放进 type 字段。当前元数据读取只检查 type,因此代码生成会丢失自增语义。
变更
验证
实验
创建
generated_ids (id INTEGER PRIMARY KEY AUTOINCREMENT, value TEXT)后,修复前 id 的 auto_increment 为 false,修复后为 true;value 仍为 false。风险与边界
仅补充 SQLite DDL 元数据读取,不改变其他数据库 SQL;未建立可比性能基准,性能数据未测量。
Closes #105