Repository navigation
🐛 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.
关联 Issue
Closes #105
背景(Situation)
SQLite 的
PRAGMA table_info对INTEGER PRIMARY KEY AUTOINCREMENT只返回INTEGER,不会把AUTOINCREMENT写入 type 字段。原元数据读取只检查 type,代码生成因此丢失自增语义。任务(Task)
从 SQLite catalog 读取表 DDL,准确区分带
AUTOINCREMENT的 INTEGER 主键和普通主键;保持表名参数化和其他数据库查询路径不变。行动(Action)
sqlite_master的表定义并检测AUTOINCREMENT关键字。auto_increment=true。验证(Verification)
环境:Windows 11,Python 3.12.12 / SQLite 3.50.4。
PYTHONPATH=src python -m pytest tests/unit/ -q:650 passed。git diff --check:通过。实验与证据(Evidence)
创建
generated_ids (id INTEGER PRIMARY KEY AUTOINCREMENT, value TEXT)后,修复前 id 的auto_increment为 false,修复后为 true;value和普通INTEGER PRIMARY KEY保持 false。表名通过?参数传递,未拼接进 catalog SQL。兼容性、风险与回滚